List of utility methods to do JButton Create
JButton | createToolBarButton(Action action) create Tool Bar Button JButton button = new JButton(); button.putClientProperty("hideActionText", true); button.setFocusable(false); button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setAction(action); return button; |
JButton | createToolBarButton(String text, Icon icon) create Tool Bar Button final JButton btn; if (icon == null) { btn = new JButton(text); } else { btn = new JButton(icon); btn.setToolTipText(text); btn.setBorderPainted(false); btn.setMargin(ZERO_INSETS); ... |
JToggleButton | createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al) create Tool Bar Toggle Button JToggleButton button = new JToggleButton(ic); fixButton(button, toolTip); if (al != null) button.addActionListener(al); return button; |
JButton | createTransparentButton(Action action, boolean withText) create Transparent Button JButton button = new JButton(action); if (withText) { button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setHorizontalTextPosition(SwingConstants.CENTER); } else { button.setText(""); button.setMargin(new Insets(0, 0, 0, 0)); button.setOpaque(false); button.setContentAreaFilled(false); button.setBorderPainted(false); return button; |
JButton | getCreateButton() get Create Button createButton.setToolTipText("New project"); return createButton; |
JButton | makeButton(Action action) make Button JButton button = new JButton(action); return button; |
JButton | makeButton(String name, ActionListener l) Return a button with action command set to name. JButton button = new JButton(name); button.addActionListener(l); button.setActionCommand(name); return button; |
void | makeButtonActLikeLabel(JButton button) Makes a button to act and look like a label, while keeping the action performed events. button.setFocusPainted(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setContentAreaFilled(false);
button.setBorderPainted(false);
button.setOpaque(false);
|
JPanel | makeButtonBar(int align, Component... comps) make Button Bar JPanel pan = new JPanel(new FlowLayout(align)); for (Component component : comps) { pan.add(component); return pan; |
void | makeButtonFlat(AbstractButton button) make Button Flat if (button instanceof JToggleButton) { button.setUI(new BasicToggleButtonUI()); } else { button.setUI(new BasicButtonUI()); button.setRolloverEnabled(true); UIDefaults table = UIManager.getLookAndFeelDefaults(); button.setBorder(new BasicBorders.RolloverButtonBorder(table.getColor("controlShadow"), ... |