javax.swing.JComponent#getParent ( )源码实例Demo

下面列出了javax.swing.JComponent#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: visualvm   文件: MemorySamplerViewSupport.java
private void activateSearch() {
    JComponent panel = getBottomPanel();

    if (searchPanel == null) {
        searchPanel = SearchUtils.createSearchPanel(table);
        panel.add(searchPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }

    panel.setVisible(true);

    searchPanel.setVisible(true);
    searchPanel.requestFocusInWindow();
}
 
源代码2 项目: visualvm   文件: ThreadsCPUView.java
private void activateFilter() {
    JComponent panel = getBottomPanel();
    
    if (filterPanel == null) {
        filterPanel = FilterUtils.createFilterPanel(table, null);
        panel.add(filterPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    filterPanel.setVisible(true);
    filterPanel.requestFocusInWindow();
}
 
源代码3 项目: netbeans   文件: DataView.java
public void activateFilter() {
    JComponent panel = getBottomPanel();
    
    if (filterPanel == null) {
        filterPanel = FilterUtils.createFilterPanel(getResultsComponent(), getExcludesFilter(), getFilterOptions());
        panel.add(filterPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    filterPanel.setVisible(true);
    filterPanel.requestFocusInWindow();
}
 
源代码4 项目: visualvm   文件: MemoryView.java
private void activateSearch() {
    JComponent panel = getBottomPanel();
    
    if (searchPanel == null) {
        searchPanel = SearchUtils.createSearchPanel(table);
        panel.add(searchPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    searchPanel.setVisible(true);
    searchPanel.requestFocusInWindow();
}
 
源代码5 项目: visualvm   文件: MemoryView.java
private void activateSearch() {
    JComponent panel = getBottomPanel();
    
    if (searchPanel == null) {
        searchPanel = SearchUtils.createSearchPanel(table);
        panel.add(searchPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    searchPanel.setVisible(true);
    searchPanel.requestFocusInWindow();
}
 
源代码6 项目: freecol   文件: QuickActionMenu.java
/**
 * Add specific menu items for a given component.
 *
 * @param comp The specific {@code JComponent}.
 * @return This {@code QuickActionMenu}.
 */
public QuickActionMenu addMenuItems(JComponent comp) {
    if (comp instanceof UnitLabel) {
        createUnitMenu((UnitLabel)comp);
    } else if (comp instanceof GoodsLabel) {
        createGoodsMenu((GoodsLabel)comp);
    } else if (comp instanceof MarketLabel) {
        createMarketMenu((MarketLabel)comp);
    } else if (comp instanceof ASingleTilePanel) {
        createTileMenu((ASingleTilePanel)comp);
    } else if (comp.getParent() instanceof ASingleTilePanel) {
        // Also check the parent to show the popup in the
        // center of the colony panel tile.
        createTileMenu((ASingleTilePanel)comp.getParent());
    }
    return this;
}
 
源代码7 项目: seaglass   文件: RootPaneNoFrameState.java
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c.getParent();

    if (true)
        return ((JRootPane) c).getWindowDecorationStyle() == JRootPane.NONE;

    if (parent instanceof JFrame)
        return true;

    if (parent instanceof JInternalFrame)
        return true;

    if (parent instanceof JDialog)
        return true;

    return false;
}
 
源代码8 项目: rapidminer-studio   文件: ToggleButtonUI.java
@Override
public Dimension getPreferredSize(JComponent c) {
	if (c.getParent() instanceof JToolBar) {
		return new Dimension((int) super.getPreferredSize(c).getWidth() + 6,
				(int) super.getPreferredSize(c).getHeight() + 6);
	} else {
		return new Dimension((int) super.getPreferredSize(c).getWidth() + 10, (int) super.getPreferredSize(c)
				.getHeight() + 6);
	}
}
 
源代码9 项目: seaglass   文件: SpinnerPreviousButtonPainter.java
private void paintButton(Graphics2D g, JComponent c, int width, int height) {
    boolean useToolBarColors = isInToolBar(c);
    Shape s;

    JSpinner spinner = (JSpinner) c.getParent();
    boolean editorFocused = false;
    JComponent editor = spinner.getEditor();
    if (editor instanceof DefaultEditor) {
        editorFocused = ((DefaultEditor)editor).getTextField().isFocusOwner();
    }
    if (focused || editorFocused) {
        s = createButtonShape(0, 0, width, height, CornerSize.OUTER_FOCUS);
        g.setPaint(getFocusPaint(s, FocusType.OUTER_FOCUS, useToolBarColors));
        g.fill(s);

        s = createButtonShape(0, 0, width - 1, height - 1, CornerSize.INNER_FOCUS);
        g.setPaint(getFocusPaint(s, FocusType.INNER_FOCUS, useToolBarColors));
        g.fill(s);
    }

    s = createButtonShape(0, 0, width - 2, height - 2, CornerSize.BORDER);
    g.setPaint(getSpinnerPrevBorderPaint(s, type));
    g.fill(s);

    s = createButtonShape(1, 1, width - 4, height - 4, CornerSize.INTERIOR);
    g.setPaint(getSpinnerPrevInteriorPaint(s, type));
    g.fill(s);

    s = shapeGenerator.createRectangle(1, 0, width - 4, 1);
    g.setPaint(getSpinnerPrevTopLinePaint(s, type));
    g.fill(s);
}
 
源代码10 项目: netbeans   文件: SystemAction.java
/** Create an icon.
* @param comp a component, which must be unattached to a container
*             and should not be used for other purposes
*/
public ComponentIcon(JComponent comp) {
    if (comp.getParent() != null) {
        throw new IllegalArgumentException();
    }

    this.comp = comp;

    Dimension size = comp.getPreferredSize();

    // Careful! If you have e.g. a JLabel with empty text, width = 0 => exceptions.
    // Must make sure it is at least a reasonable size.
    comp.setSize(Math.max(size.width, 16), Math.max(size.height, 16));
}
 
源代码11 项目: netbeans   文件: SearchPanel.java
/**
 * Shows the given component in the main area of the layout.
 * 
 * @param component component to show.
 */
private void showComponent(JComponent component) {
    if (component.getParent() == null) {
        JComponent shownComponent = (component == messageLabel) ? searchPanel : messageLabel;
        ((GroupLayout)getLayout()).replace(shownComponent, component);
    }
}
 
源代码12 项目: netbeans   文件: SearchPanel.java
/**
 * Shows the given component in the main area of the layout.
 * 
 * @param component component to show.
 */
private void showComponent(JComponent component) {
    if (component.getParent() == null) {
        JComponent shownComponent = (component == messageLabel) ? searchPanel : messageLabel;
        ((GroupLayout)getLayout()).replace(shownComponent, component);
    }
}
 
源代码13 项目: stendhal   文件: StyledToolTipUI.java
@Override
public void paint(Graphics g, JComponent tooltip) {
	// Get rid of popup borders, if it has any (Heavy weight popups tend to
	// pack the tooltip in a JPanel
	Container parent = tooltip.getParent();
	if (parent instanceof JComponent) {
		JComponent popup = (JComponent) parent;
		if (popup.getBorder() != null) {
			popup.setBorder(null);
		}
	}
	super.paint(g, tooltip);
}
 
源代码14 项目: seaglass   文件: SpinnerNextButtonPainter.java
private void paintButton(Graphics2D g, JComponent c, int width, int height) {
    boolean useToolBarColors = isInToolBar(c);
    Shape s;

    JSpinner spinner = (JSpinner) c.getParent();
    boolean editorFocused = false;
    JComponent editor = spinner.getEditor();
    if (editor instanceof DefaultEditor) {
        editorFocused = ((DefaultEditor)editor).getTextField().isFocusOwner();
    }
    if (focused || editorFocused) {
        s = createButtonShape(0, 0, width, height, CornerSize.OUTER_FOCUS);
        g.setPaint(getFocusPaint(s, FocusType.OUTER_FOCUS, useToolBarColors));
        g.fill(s);

        s = createButtonShape(0, 1, width - 1, height - 1, CornerSize.INNER_FOCUS);
        g.setPaint(getFocusPaint(s, FocusType.INNER_FOCUS, useToolBarColors));
        g.fill(s);
    }

    s = createButtonShape(0, 2, width - 2, height - 2, CornerSize.BORDER);
    g.setPaint(getSpinnerNextBorderPaint(s, type));
    g.fill(s);

    s = createButtonShape(1, 3, width - 4, height - 4, CornerSize.INTERIOR);
    g.setPaint(getSpinnerNextInteriorPaint(s, type));
    g.fill(s);
}
 
源代码15 项目: netbeans   文件: CssStylesTC.java
private void setContent(JComponent component) {
    if(component.getParent() == null) {
        //not shown
        removeAll();
        add(component, BorderLayout.CENTER);
        revalidate();
        repaint();
    }
}
 
源代码16 项目: rapidminer-studio   文件: RadioButtonUI.java
@Override
public synchronized void paint(Graphics g, JComponent c) {
	// without this, checkboxes and radio buttons have a fixed bg color instead of using the bg
	// color of the container they are in
	if (c.getParent() != null) {
		c.setBackground(c.getParent().getBackground());
	}
	super.paint(g, c);
}
 
源代码17 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, javax.swing.JComponent)
 */
public void update(Graphics g, JComponent c) {
    SeaGlassContext context = getContext(c);

    SeaGlassLookAndFeel.update(context, g);
    if (((JRootPane) c).getWindowDecorationStyle() != JRootPane.NONE) {
        context.getPainter().paintRootPaneBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
    } else if (PlatformUtils.isMac()) {
        // We may need to paint the rootpane on a Mac if the window is
        // decorated.
        boolean   shouldPaint       = false;
        Container toplevelContainer = c.getParent();

        if (toplevelContainer instanceof JFrame) {
            shouldPaint = !((JFrame) toplevelContainer).isUndecorated();
        }

        if (shouldPaint) {
            if (!paintTextured) {
                g.setColor(c.getBackground());
                g.fillRect(0, 0, c.getWidth(), c.getHeight());
            } else if (isWindowFocused.isInState(c)) {
                contentActive.paint((Graphics2D) g, c, c.getWidth(), c.getHeight());
            } else {
                contentInactive.paint((Graphics2D) g, c, c.getWidth(), c.getHeight());
            }
        }
    }

    paint(context, g);
    context.dispose();
}
 
源代码18 项目: keystore-explorer   文件: CursorUtil.java
private static JDialog findContainingDialog(JComponent component) {
	Container container = component.getParent();

	while (container != null) {
		if (container instanceof JDialog) {
			return (JDialog) container;
		}

		container = container.getParent();
	}

	return null;
}
 
源代码19 项目: rapidminer-studio   文件: ProgressBarUI.java
@Override
protected void paintDeterminate(Graphics g, JComponent c) {
	boolean compressed = Boolean.parseBoolean(String.valueOf(progressBar
			.getClientProperty(RapidLookTools.PROPERTY_PROGRESSBAR_COMPRESSED)));

	int y = 0;
	int x = 0;
	int w;
	int h;
	if (compressed) {
		x = (int) (c.getWidth() * 0.67);
		w = (int) (c.getWidth() * 0.33);
		y = 3;
		h = c.getHeight() - 6;
	} else {
		w = c.getWidth();
		h = c.getHeight() / 2;
	}

	int amountFull = getAmountFull(progressBar.getInsets(), w, h);

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	if (c.isOpaque()) {
		if (c.getParent() != null) {
			g2.setColor(c.getParent().getBackground());
		} else {
			g2.setColor(c.getBackground());
		}
		g2.fillRect(x, y, c.getWidth(), c.getHeight());
	}

	g2.setColor(Colors.PROGRESSBAR_BACKGROUND);
	g2.fillRoundRect(x + 1, y + 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	g2.setColor(Colors.PROGRESSBAR_BORDER);
	g2.drawRoundRect(x + 1, y + 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	Paint gp = new GradientPaint(x, y + 3, Colors.PROGRESSBAR_DETERMINATE_FOREGROUND_GRADIENT_START, x, h - 5,
			Colors.PROGRESSBAR_DETERMINATE_FOREGROUND_GRADIENT_END);
	g2.setPaint(gp);
	g2.fillRoundRect(x + 3, y + 3, amountFull - 5, h - 5, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2);

	drawString(g2, w, h, compressed);
}
 
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c.getParent();

    return parent instanceof JComboBox && ((JComboBox) parent).isEditable();
}