List of usage examples for javax.swing JButton JButton
public JButton()
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); Box box = new Box(BoxLayout.X_AXIS); box.add(component1);//from w w w . j a v a 2 s . c om box.add(Box.createGlue()); box.add(component2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); Box box = new Box(BoxLayout.X_AXIS); int width = 10; box.add(Box.createHorizontalStrut(width)); box.add(component1);//from ww w. j av a 2 s.co m }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); int align = FlowLayout.CENTER; // or LEFT, RIGHT JPanel panel = new JPanel(new FlowLayout(align)); panel.add(component1);//www. j a v a2s. com panel.add(component2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton button = new JButton(); // Icon will appear gray button.setEnabled(false);/*from w w w . ja va 2 s . co m*/ // Set a disabled version of icon Icon disabledIcon = new ImageIcon("d.gif"); button.setDisabledIcon(disabledIcon); // To remove the disabled version of the icon, set to null button.setDisabledIcon(null); button.setDisabledIcon(new ImageIcon("icon.gif")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); Box box = new Box(BoxLayout.X_AXIS); box = Box.createHorizontalBox(); // Add components box.add(component1);/*from w w w . j av a 2 s .c om*/ box.add(component2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); // Create vertical box container Box box = new Box(BoxLayout.Y_AXIS); // create a vertical box container box = Box.createVerticalBox(); // Add components box.add(component1);// w w w .j a va2 s. c o m box.add(component2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); int rows = 2; int cols = 2; JPanel panel = new JPanel(new GridLayout(rows, cols)); panel.add(component1);/*from w w w . jav a 2 s . c o m*/ panel.add(component2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton button = new JButton(); // Add rollover icon Icon rolloverIcon = new ImageIcon("r.gif"); button.setRolloverIcon(rolloverIcon); // Add pressed icon Icon pressedIcon = new ImageIcon("p.gif"); button.setPressedIcon(pressedIcon);/* www. jav a2 s. co m*/ // To remove rollover icon, set to null button.setRolloverIcon(null); // To remove pressed icon, set to null button.setPressedIcon(null); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); Icon pressedIcon = new ImageIcon("pres-icon.gif"); button.setPressedIcon(pressedIcon);//from w ww. j a v a 2 s. c om JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); // Icon will appear gray button.setEnabled(false);/*from w ww . j a v a 2 s.c om*/ // Set a disabled version of icon Icon disabledIcon = new ImageIcon("d.gif"); button.setDisabledIcon(disabledIcon); // To remove the disabled version of the icon, set to null button.setDisabledIcon(null); button.setDisabledIcon(new ImageIcon("icon.gif")); JOptionPane.showMessageDialog(null, button); }