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() 

Source Link

Document

Creates a button with no set text or icon.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton();
    button.setText("<html>" + "This is a" + "<br><i>" + "swing button" + "</i></html>");

}

From source file:Main.java

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

    JButton button = new JButton();
    button.setText("<html><center>" + "This is a" + "<br>" + "swing button" + "</center></html>");

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    component.setToolTipText("<html>" + "This is a" + "<br><i>" + "tool tip" + "</i></html>");

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    String imageName = "file:image.jpg";
    component.setToolTipText("<html>Here is an image <img src=" + imageName + "></html>");

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton();
    // Get gap size; default is 4
    int gapSize = button.getIconTextGap();

    // Set gap size
    button.setIconTextGap(8);/*from   w ww  . j a  v a 2s  .  co  m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    JPanel panel = new JPanel(null);
    component.setBounds(1, 1, 100, 100);
    panel.add(component);/* ww  w .j a  v  a 2 s  .c o  m*/
}

From source file:Main.java

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

    // Get gap size; default is 4
    int gapSize = button.getIconTextGap();

    // Set gap size
    button.setIconTextGap(8);//from  w  w  w. j a v a 2  s. c o m

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton();
    // Add or change the icon; it will appear to the left of the text
    button.setIcon(new ImageIcon("icon.gif"));

    // Set to null to remove icon
    button.setIcon(null);//from www . ja v  a 2 s.  c o m
}

From source file:Main.java

public static void main(String[] argv) {
    JButton component = new JButton();
    Point pt = new Point(component.getLocation());

    SwingUtilities.convertPointFromScreen(pt, component);
}

From source file:Main.java

public static void main(String[] argv) {

    JButton component = new JButton();
    Point pt = new Point(component.getLocation());
    SwingUtilities.convertPointToScreen(pt, component);
}