Beispiel #1
0
 /**
  * Creates a new checkbox with manageable width.
  *
  * @param aText Text of the checkbox.
  * @param aToolTip Tooltip text for the checkbox. Set this to <code>null</code> if no tooltip is
  *     to be displayed.
  * @param aListener Checkbox click's listener.
  * @return Newly created instance of <code>JCheckBox</code>.
  */
 public static JCheckBox createCheckBox(String aText, String aToolTip, ActionListener aListener) {
   JCheckBox button = new JCheckBox(aText);
   button.setToolTipText(aToolTip);
   button.addActionListener(aListener);
   button.setMaximumSize(new Dimension(Short.MAX_VALUE, button.getHeight()));
   return button;
 }
 /** Creates an image of the checkbox and puts it in a label. */
 private JLabel createIconLabel(JCheckBox checkBox) {
   checkBox.setOpaque(false);
   checkBox.setSize(checkBox.getMinimumSize());
   Image image =
       new BufferedImage(checkBox.getWidth(), checkBox.getHeight(), Transparency.TRANSLUCENT);
   Graphics g = image.getGraphics();
   checkBox.paint(g);
   g.dispose();
   return new JLabel(new ImageIcon(image));
 }