Java Code Examples for javax.swing.JLabel#getDisabledIcon()

The following examples show how to use javax.swing.JLabel#getDisabledIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RotateLabelUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private String layout(JLabel label, FontMetrics fm, int width, int height) {
    Insets insets = label.getInsets(paintViewInsets);
    String text = label.getText();
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
    paintViewR.x = insets.left;
    paintViewR.y = insets.top;

    if (vertical) {
        paintViewR.height = width - (insets.left + insets.right);
        paintViewR.width = height - (insets.top + insets.bottom);
    } else {
        paintViewR.width = width - (insets.left + insets.right);
        paintViewR.height = height - (insets.top + insets.bottom);
    }

    paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
    paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
    return layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);
}
 
Example 2
Source File: SeaGlassLabelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
protected void paint(SeaGlassContext context, Graphics g) {
    JLabel label = (JLabel) context.getComponent();
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();

    g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
    g.setFont(style.getFont(context));
    context.getStyle().getGraphicsUtils(context).paintText(context, g, label.getText(), icon, label.getHorizontalAlignment(),
        label.getVerticalAlignment(), label.getHorizontalTextPosition(), label.getVerticalTextPosition(),
        label.getIconTextGap(), label.getDisplayedMnemonicIndex(), 0);
}
 
Example 3
Source File: SeaGlassLabelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
public Dimension getPreferredSize(JComponent c) {
    JLabel label = (JLabel) c;
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
    SeaGlassContext context = getContext(c);
    Dimension size = context.getStyle().getGraphicsUtils(context).getPreferredSize(context,
        context.getStyle().getFont(context), label.getText(), icon, label.getHorizontalAlignment(),
        label.getVerticalAlignment(), label.getHorizontalTextPosition(), label.getVerticalTextPosition(),
        label.getIconTextGap(), label.getDisplayedMnemonicIndex());

    context.dispose();
    return size;
}
 
Example 4
Source File: SeaGlassLabelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
public Dimension getMinimumSize(JComponent c) {
    JLabel label = (JLabel) c;
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
    SeaGlassContext context = getContext(c);
    Dimension size = context.getStyle().getGraphicsUtils(context).getMinimumSize(context, context.getStyle().getFont(context),
        label.getText(), icon, label.getHorizontalAlignment(), label.getVerticalAlignment(), label.getHorizontalTextPosition(),
        label.getVerticalTextPosition(), label.getIconTextGap(), label.getDisplayedMnemonicIndex());

    context.dispose();
    return size;
}
 
Example 5
Source File: SeaGlassLabelUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
public Dimension getMaximumSize(JComponent c) {
    JLabel label = (JLabel) c;
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
    SeaGlassContext context = getContext(c);
    Dimension size = context.getStyle().getGraphicsUtils(context).getMaximumSize(context, context.getStyle().getFont(context),
        label.getText(), icon, label.getHorizontalAlignment(), label.getVerticalAlignment(), label.getHorizontalTextPosition(),
        label.getVerticalTextPosition(), label.getIconTextGap(), label.getDisplayedMnemonicIndex());

    context.dispose();
    return size;
}
 
Example 6
Source File: RotateLabelUI.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public void paint(Graphics g, JComponent c) {
      JLabel label = (JLabel)c;
      String text = label.getText();
      Icon icon = label.isEnabled() ? label.getIcon() : label.getDisabledIcon();

      if (icon == null && text == null) return;

      Graphics2D g2 = (Graphics2D) g;
  	AffineTransform transform = null;

      if (rotation != ROTATE_0) {
          transform = g2.getTransform();
          g2.rotate(rotation);
          
          if (rotation == ROTATE_90) {
              g2.translate(0, -c.getWidth());
          } else if (rotation == ROTATE_180) {
              g2.translate(-c.getWidth(), -c.getHeight());
          } else if (rotation == ROTATE_270) {
              g2.translate(-c.getHeight(), 0);
          }
      }

      FontMetrics fm = g.getFontMetrics();
      String clippedText = layout(label, fm, c.getWidth(), c.getHeight());

      if (icon != null) icon.paintIcon(c, g, paintIconR.x, paintIconR.y);

      if (text != null) {
   View v = (View)c.getClientProperty(BasicHTML.propertyKey);
   if (v != null) {
v.paint(g, paintTextR);
   } else {
int textX = paintTextR.x;
int textY = paintTextR.y + fm.getAscent();

if (label.isEnabled()) {
    paintEnabledText(label, g, clippedText, textX, textY);
} else {
    paintDisabledText(label, g, clippedText, textX, textY);
}
   }
      }

      if (transform != null) g2.setTransform(transform);
  }
 
Example 7
Source File: VerticalLabelUI.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
@Override
   public void paint(Graphics g, JComponent c) {
       JLabel label = (JLabel)c;
       String text = label.getText();
       Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();

       if ((icon == null) && (text == null)) {
           return;
       }

       FontMetrics fm = g.getFontMetrics();
       paintViewInsets = c.getInsets(paintViewInsets);

       paintViewR.x = paintViewInsets.left;
       paintViewR.y = paintViewInsets.top;

   	// Use inverted height & width
       paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
       paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

       paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
       paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;

       String clippedText = layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);

   	Graphics2D g2 = (Graphics2D) g;
   	AffineTransform tr = g2.getTransform();
   	if (clockwise) {
           g2.rotate( Math.PI / 2 );
           g2.translate( 0, - c.getWidth() );
   	} else {
           g2.rotate( - Math.PI / 2 );
           g2.translate( - c.getHeight(), 0 );
   	}

   	if (icon != null) {
           icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
       }

       if (text != null) {
           int textX = paintTextR.x;
           int textY = paintTextR.y + fm.getAscent();

           if (label.isEnabled()) {
               paintEnabledText(label, g, clippedText, textX, textY);
           } else {
               paintDisabledText(label, g, clippedText, textX, textY);
           }
       }
g2.setTransform( tr );
   }
 
Example 8
Source File: VerticalLabelUI.java    From pdfxtk with Apache License 2.0 4 votes vote down vote up
public void paint(Graphics g, JComponent c) {
   JLabel label = (JLabel)c;
   String text  = label.getText();
   Icon   icon  = label.isEnabled() ? label.getIcon() : label.getDisabledIcon();
   
   if(icon == null && text == null) return;
 
   FontMetrics  fm = g.getFontMetrics();
   paintViewInsets = c.getInsets(paintViewInsets);
   
   paintViewR.x      = paintViewInsets.top;
   paintViewR.y      = paintViewInsets.left;
   paintViewR.width  = c.getHeight() - (paintViewInsets.top  + paintViewInsets.bottom);
   paintViewR.height = c.getWidth()  - (paintViewInsets.left + paintViewInsets.right);
   
   paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
   paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
   
   String clippedText = 
     layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);
   
   Graphics2D      g2 = (Graphics2D)g;
   AffineTransform tr = g2.getTransform();
   if(clockwise) {
     g2.rotate(Math.PI / 2); 
     g2.translate(0, - c.getWidth());
   } else {
     g2.rotate(-Math.PI / 2); 
     g2.translate(-c.getHeight(), 0);
   }
   
   if (icon != null) {
     icon.paintIcon(c, g2, paintIconR.x, paintIconR.y);
   }
   
   if (text != null) {
     View v = (View) c.getClientProperty(BasicHTML.propertyKey);
     if (v != null) {
v.paint(g2, paintTextR);
     } else {
int textX = paintTextR.x;
int textY = paintTextR.y + fm.getAscent();

if (label.isEnabled())
  paintEnabledText(label, g2, clippedText, textX, textY);
else
  paintDisabledText(label, g2, clippedText, textX, textY);
     }
   }
 }