예제 #1
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   AbstractButton b = (AbstractButton) c;
   ButtonModel model = b.getModel();
   if (b.isSelected() == true) {
     g.fillRoundRect(x + 3, y + 3, getIconWidth() - 6, getIconHeight() - 6, 4, 4);
   }
 }
 @Override
 public JComponent getPreferredFocusedComponent() {
   final Enumeration<AbstractButton> enumeration = myGroup.getElements();
   while (enumeration.hasMoreElements()) {
     final AbstractButton button = enumeration.nextElement();
     if (button.isSelected()) {
       return button;
     }
   }
   return myPanel;
 }
예제 #3
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Icon lafIcon = getLaFIcon();
   if (lafIcon != null) {
     lafIcon.paintIcon(c, g, x, y);
     return;
   }
   assert menuItem == null || c == menuItem;
   Icon icon = getIcon();
   if (type == JCheckBoxMenuItem.class || type == JRadioButtonMenuItem.class) {
     AbstractButton b = (AbstractButton) c;
     if (b.isSelected()) {
       Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
       Part part = Part.MP_POPUPCHECK;
       State backgroundState;
       State state;
       if (isEnabled(c, null)) {
         backgroundState = (icon != null) ? State.BITMAP : State.NORMAL;
         state =
             (type == JRadioButtonMenuItem.class) ? State.BULLETNORMAL : State.CHECKMARKNORMAL;
       } else {
         backgroundState = State.DISABLEDPUSHED;
         state =
             (type == JRadioButtonMenuItem.class)
                 ? State.BULLETDISABLED
                 : State.CHECKMARKDISABLED;
       }
       Skin skin;
       XPStyle xp = XPStyle.getXP();
       skin = xp.getSkin(c, backgroundPart);
       skin.paintSkin(g, x, y, getIconWidth(), getIconHeight(), backgroundState);
       if (icon == null) {
         skin = xp.getSkin(c, part);
         skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
       }
     }
   }
   if (icon != null) {
     icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
   }
 }
    public void actionPerformed(final ActionEvent ae) {
      AbstractButton btn = (AbstractButton) ae.getSource();

      System.out.println("Action 3 performed.");
      SharedActions.setActionSelected(SharedActions.ACTION4_KEY, btn.isSelected());
    }