當前位置: 首頁>>代碼示例>>Java>>正文


Java JComponent.isOpaque方法代碼示例

本文整理匯總了Java中javax.swing.JComponent.isOpaque方法的典型用法代碼示例。如果您正苦於以下問題:Java JComponent.isOpaque方法的具體用法?Java JComponent.isOpaque怎麽用?Java JComponent.isOpaque使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JComponent的用法示例。


在下文中一共展示了JComponent.isOpaque方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paint

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void paint(Graphics g, JComponent c) {
    LAFUtilities.setProperties(g, c);

    if (c.isOpaque()) {
        ImageLibrary.drawTiledImage("image.background.FreeColButton", g, c, null);
    }
    super.paint(g, c);

    AbstractButton a = (AbstractButton) c;
    if (a.isRolloverEnabled()) {
        Point p = MouseInfo.getPointerInfo().getLocation();
        SwingUtilities.convertPointFromScreen(p, c);
        boolean rollover = c.contains(p);
        if (rollover) {
            paintButtonPressed(g, (AbstractButton) c);
        }
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:20,代碼來源:FreeColButtonUI.java

示例2: createContentImage

import javax.swing.JComponent; //導入方法依賴的package包/類
private BufferedImage createContentImage( JComponent c, Dimension contentSize ) {
    GraphicsConfiguration cfg = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();

    boolean opaque = c.isOpaque();
    c.setOpaque(true);
    BufferedImage res = cfg.createCompatibleImage(contentSize.width, contentSize.height);
    Graphics2D g = res.createGraphics();
    g.setColor( c.getBackground() );
    g.fillRect(0, 0, contentSize.width, contentSize.height);
    g.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f ));
    c.paint(g);
    c.setOpaque(opaque);
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:DnDSupport.java

示例3: update

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void update(Graphics g, JComponent c) {
	if (c.isOpaque()) {
		Color oldColor = g.getColor();
		CachedPainter.drawMenuBarBackground(c, g, 0, 0, c.getWidth(), c.getHeight());
		g.setColor(oldColor);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:9,代碼來源:MenuBarUI.java

示例4: setOpaqueLayerRecursive

import javax.swing.JComponent; //導入方法依賴的package包/類
private static void setOpaqueLayerRecursive(Component opaqueComponent) {
    if (opaqueComponent instanceof JTextArea ||
        opaqueComponent instanceof JLabel) {
        if (opaqueComponent.isOpaque()) {
            ((JComponent) opaqueComponent).setOpaque(false);
        }
    } else if (opaqueComponent instanceof JPanel) {
        JComponent panel = (JComponent)opaqueComponent;
        if (panel.isOpaque()) {
            panel.setOpaque(false);
        }
        iterateOverOpaqueLayersComponents(panel);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:15,代碼來源:FreeColDialog.java

示例5: paint

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void paint(Graphics g, JComponent c) {
    if (c.isOpaque()) {
        ImageLibrary.drawTiledImage("image.background.FreeColOptionPane",
                                    g, c, null);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:11,代碼來源:FreeColOptionPaneUI.java

示例6: paint

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void paint(Graphics g, JComponent c) {
    if (c.isOpaque()) {
        ImageLibrary.drawTiledImage("image.background.FreeColToolTip", g, c, null);
    }

    g.setColor(Color.BLACK); // FIXME: find out why this is necessary

    Graphics2D graphics = (Graphics2D)g;
    float x = margin;
    float y = margin;
    for (String line : lineBreak.split(((JToolTip) c).getTipText())) {
        if (line.isEmpty()) {
            y += LEADING;
            continue;
        }
        AttributedCharacterIterator styledText =
            new AttributedString(line).getIterator();

        LineBreakMeasurer measurer = new LineBreakMeasurer(styledText, frc);

        while (measurer.getPosition() < styledText.getEndIndex()) {

            TextLayout layout = measurer.nextLayout(maximumWidth);

            y += (layout.getAscent());
            float dx = layout.isLeftToRight() ?
                0 : (maximumWidth - layout.getAdvance());

            layout.draw(graphics, x + dx, y);
            y += layout.getDescent() + layout.getLeading();
        }
    }
 }
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:35,代碼來源:FreeColToolTipUI.java

示例7: paintBackground

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void paintBackground(java.awt.Graphics g) {
    JComponent c = getComponent();
    if (c.isOpaque()) {
        ImageLibrary.drawTiledImage("image.background.FreeColTextArea", g, c, null);
    }
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:8,代碼來源:FreeColTextAreaUI.java

示例8: update

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public final void update(final Graphics g, final JComponent c) {
    if (c.isOpaque()) {
        AquaUtils.fillRect(g, c);
    }
    paint(g, c);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:AquaPanelUI.java

示例9: paintBackground

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public void paintBackground(java.awt.Graphics g) {
    JComponent c = getComponent();

    if (c.isOpaque()) {
        ImageLibrary.drawTiledImage("image.background.FreeColTextField", g, c, null);
    }
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:9,代碼來源:FreeColTextFieldUI.java

示例10: paintDeterminate

import javax.swing.JComponent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:50,代碼來源:ProgressBarUI.java

示例11: paintIndeterminate

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
protected void paintIndeterminate(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;
	}

	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);

	// make sure we don't draw over the boundaries
	RoundRectangle2D clipRect = new RoundRectangle2D.Double(x + 3, y + 3, w - 5, h - 5,
			RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2);
	g2.setClip(clipRect);

	for (double xCoord = x + -4 * ANIMATION_BAR_LENGTH + System.currentTimeMillis() * ANIMATION_SPEED
			% (2 * ANIMATION_BAR_LENGTH); xCoord < x + w + 2 * ANIMATION_BAR_LENGTH;) {
		g2.setColor(Colors.PROGRESSBAR_INDETERMINATE_FOREGROUND_1);
		g2.fill(createIntermediateShape(xCoord, ANIMATION_BAR_LENGTH, h));
		xCoord += ANIMATION_BAR_LENGTH;
		g2.setColor(Colors.PROGRESSBAR_INDETERMINATE_FOREGROUND_2);
		g2.fill(createIntermediateShape(xCoord, ANIMATION_BAR_LENGTH, h));
		xCoord += ANIMATION_BAR_LENGTH;
	}
	g2.setClip(null);

	drawString(g2, w, h, compressed);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:58,代碼來源:ProgressBarUI.java

示例12: update

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * Notifies this UI delegate that it is time to paint the specified
 * component.  This method is invoked by <code>JComponent</code>
 * when the specified component is being painted.
 *
 * <p>By default this method fills the specified component with
 * its background color if its {@code opaque} property is {@code true},
 * and then immediately calls {@code paint}. In general this method need
 * not be overridden by subclasses; all look-and-feel rendering code should
 * reside in the {@code paint} method.
 *
 * @param g the <code>Graphics</code> context in which to paint
 * @param c the component being painted;
 *          this argument is often ignored,
 *          but might be used if the UI object is stateless
 *          and shared by multiple components
 *
 * @see #paint
 * @see javax.swing.JComponent#paintComponent
 */
public void update(Graphics g, JComponent c) {
    if (c.isOpaque()) {
        g.setColor(c.getBackground());
        g.fillRect(0, 0, c.getWidth(),c.getHeight());
    }
    paint(g, c);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:ComponentUI.java


注:本文中的javax.swing.JComponent.isOpaque方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。