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

The following examples show how to use javax.swing.JLabel#isEnabled() . 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: PlayerFunctions.java    From aurous-app with GNU General Public License v2.0 5 votes vote down vote up
public static void handleSpecialLabels(final boolean isRepeat) {
	final JLabel repeatStatusLabel = ControlPanel.repeat();
	final JLabel shuffleStatusLabel = ControlPanel.shuffle();
	if (isRepeat) {
		if (repeatStatusLabel.isEnabled()) {
			if (repeat == true) {
				repeat = false;
				repeatStatusLabel.setText("Repeat : Off");
				shuffleStatusLabel.setEnabled(true);

			} else {
				repeat = true;
				shuffle = false;
				shuffleStatusLabel.setEnabled(false);
				repeatStatusLabel.setText("Repeat : On");
				shuffleStatusLabel.setText("Shuffle : Off");
			}
		}
	} else {
		if (shuffleStatusLabel.isEnabled()) {
			if (shuffle == true) {
				shuffle = false;
				shuffleStatusLabel.setText("Shuffle : Off");
				repeatStatusLabel.setEnabled(true);

			} else {
				shuffle = true;
				repeat = false;
				repeatStatusLabel.setEnabled(false);
				shuffleStatusLabel.setText("Shuffle : On");
				repeatStatusLabel.setText("Repeat : Off");
			}
		}
	}
}
 
Example 7
Source File: DayChooser.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
public
void
doMouseEvent(MouseEvent event)
{
  JLabel label = (JLabel)event.getSource();

  if(label.isEnabled() == true)
  {
    if(Integer.parseInt(label.getText()) != getSelectedDay())
    {
      if(event.getID() == MOUSE_CLICKED && event.getButton() == BUTTON1)
      {
        getCalendar().set(DATE, Integer.valueOf(label.getText()).intValue());
        displayDays();

        getActionSignaler().sendSignal(DayChooser.this, ACTION_DAY_SELECTED);
      }
      else if(event.getID() == MOUSE_ENTERED)
      {
        label.setBorder(BORDER_SELECTED);
      }
      else if(event.getID() == MOUSE_EXITED)
      {
        label.setBorder(BORDER_NORMAL);
      }
    }
    else if(event.getClickCount() == 2)
    {
      getActionSignaler().sendSignal(DayChooser.this, ACTION_DAY_CHOSEN);
    }
  }
}
 
Example 8
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 9
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 10
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);
     }
   }
 }