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(String[] argv) throws Exception {

    JButton button = new JButton("My Button") {
        public Point getToolTipLocation(MouseEvent event) {
            return new Point(0, 0);
        }/*from  w  w w. jav a 2s  . co  m*/
    };

}

From source file:Main.java

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

    JButton button = new JButton("My Button") {
        public Point getToolTipLocation(MouseEvent event) {
            return null;
        }//from  ww w.j  a va2 s . c o  m
    };

    // Set the tool tip text
    button.setToolTipText("aString");
}

From source file:Main.java

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

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

    JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);

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

    leftComponent = (JButton) hpane.getLeftComponent();
    rightComponent = (JButton) hpane.getRightComponent();

    topComponent = (JButton) vpane.getTopComponent();
    bottomComponent = (JButton) vpane.getBottomComponent();

    hpane.setLeftComponent(topComponent);
    hpane.setRightComponent(bottomComponent);

    vpane.setTopComponent(leftComponent);
    vpane.setBottomComponent(rightComponent);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("button");
    ActionMap map = component.getActionMap();
    list(map, map.keys());//from  w  w w  .j  a v a2 s  . c  o m
    list(map, map.allKeys());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");

    String label = "Tab Label";
    pane.addTab(label, component);/*from   w  ww .  jav a  2s. c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");
    jb.setMargin(new Insets(5, 5, 5, 5));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);/* w  w  w . j  a  va  2 s  .  c  o  m*/
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");

    component.setName("Tab Label");
    pane.add(component);// ww w.  j  av a2s. c om

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");
    int index = pane.indexOfComponent(component);

    if (index < 0) {
        // The tab could not be found
    }//from  w w w.ja va  2  s.  com
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JButton button = new JButton("Click me");
    button.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Hello World!"));
    frame.getContentPane().add(button);//from   www  .  j a va2s . c o m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");
    // Remove the last tab
    pane.remove(pane.getTabCount() - 1);

    // Remove the tab with the specified child component
    pane.remove(component);/*from   w  ww.ja  va  2s  .co m*/

    // Remove all the tabs
    pane.removeAll();
}