Example usage for javax.swing JButton JButton

List of usage examples for javax.swing JButton JButton

Introduction

In this page you can find the example usage for javax.swing JButton JButton.

Prototype

public JButton(Action a) 

Source Link

Document

Creates a button where properties are taken from the Action supplied.

Usage

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Dog");

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Test");
    button.setToolTipText("Help text for the button");

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Test");

    button.addActionListener(e -> System.out.println("Button pressed"));

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) {
    JButton close = new JButton("Close me programmatically");
    final JFrame f = new JFrame("Close Me");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(close);//from   w  w w  .  j  a  v  a  2 s  . c om
    close.addActionListener(e -> {
        f.dispose();
    });
    f.pack();
    f.setLocationByPlatform(true);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton(new ImageIcon("image.gif"));
    button.setToolTipText("Button Name");

    button.getAccessibleContext().setAccessibleName("Button Name");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton button = new JButton("Button");
    button.setMnemonic('B');
    JCheckBox checkBox = new JCheckBox("CheckBox");
    checkBox.setMnemonic('C');
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");

    // Create a left-right split pane
    JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

    JSplitPane vpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComponent, bottomComponent);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton leftComponent = new JButton("left");
    JButton rightComponent = new JButton("right");

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);
    int size = pane.getDividerSize();
    size = 1;/*from  w w w.  ja  v  a 2 s .c  o  m*/
    pane.setDividerSize(size);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton topComponent = new JButton("top");
    JButton bottomComponent = new JButton("bottom");

    JSplitPane vpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComponent, bottomComponent);

    boolean b = vpane.isOneTouchExpandable(); // false by default

    vpane.setOneTouchExpandable(true);/* ww  w  .  j a v a 2s  . c o m*/

}