@Override
 protected void paintComponent(Graphics g) {
   if (isSelected()) {
     setBackground(UIManager.getColor("Tree.selectionBackground"));
     g.setColor(UIManager.getColor("Tree.selectionBackground"));
     Dimension size = getSize();
     g.fillRect(0, 0, size.width, size.height);
     setForeground(UIManager.getColor("Tree.selectionForeground"));
   } else {
     setBackground(UIManager.getColor("ToggleButton.background"));
     Color foreground = UIManager.getColor("ToggleButton.foreground");
     switch (demo.getState()) {
       case STOPPED:
         {
           foreground = visitedForeground;
           break;
         }
       case FAILED:
         {
           foreground = failedForeground;
         }
     }
     setForeground(foreground);
   }
   super.paintComponent(g);
 }
示例#2
0
 @Override
 public void paintComponent(final Graphics g) {
   this.setIcon(new ImageIcon());
   this.setText(s);
   this.setIconTextGap(31);
   super.paintComponent(g);
   this.setIcon(i);
   getIcon().paintIcon(this, g, distanzaBordoImageX, getHeight() / 2 - i.getIconHeight() / 2);
   if (this.isSelected()) {
     disegnaBottone(g, Color.GRAY, new Color(167, 243, 239));
   }
 } // end paint
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Dimension dim = getSize();
    Insets ins = getInsets();

    // if there is popup menu, paint triangle in lower right corner
    if (pop != null) {
      int x = dim.width - ins.right - i.getIconWidth();
      int y = dim.width - ins.right - i.getIconHeight();
      i.paintIcon(this, g, x, y);
    }
  }
示例#4
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (this.isSelected()) {
     g.setColor(Color.white);
     g.drawString(
         name,
         (getWidth() - g.getFontMetrics().stringWidth(name)) / 2 + 1,
         (getHeight() + g.getFontMetrics().getAscent()) / 2 - 1);
   } else {
     g.setColor(Color.black);
     g.drawString(
         name,
         (getWidth() - g.getFontMetrics().stringWidth(name)) / 2 + 1,
         (getHeight() + g.getFontMetrics().getAscent()) / 2 - 1);
   }
 }