本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}