private JButton addButton(String name, Color color) {
   JButton button = new JButton(name);
   button.setBackground(color);
   // button.setIcon(makeIcon(color, 50, 20));
   button.setAction(setColorAction);
   add(button);
   return button;
 }
Example #2
0
 public JButton createButton(Action a) {
   JButton b =
       new JButton() {
         public Dimension getMaximumSize() {
           int width = Short.MAX_VALUE;
           int height = super.getMaximumSize().height;
           return new Dimension(width, height);
         }
       };
   // setting the following client property informs the button to show
   // the action text as it's name. The default is to not show the
   // action text.
   b.putClientProperty("displayActionText", Boolean.TRUE);
   b.setAction(a);
   // b.setAlignmentX(JButton.CENTER_ALIGNMENT);
   return b;
 }