List of usage examples for javax.swing JButton JButton
public JButton(Action a)
Action
supplied. From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); JButton component = new JButton("button"); int index = 1; pane.insertTab("label", new ImageIcon("icon.png"), component, "tooltip", index); }
From source file:ToolTipDemo.java
License:asdf
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton b = new JButton("Hello, World"); frame.add(b, "Center"); b.setToolTipText("asdf"); frame.setSize(300, 200);// w w w . j a v a2s .c o m frame.setVisible(true); }
From source file:Main.java
License:asdf
public static void main(String[] argv) throws Exception { JWindow window = new JWindow(); JButton component = new JButton("asdf"); // Add component to the window window.getContentPane().add(component, BorderLayout.CENTER); // Set initial size window.setSize(300, 300);/*from ww w. j av a2 s. c om*/ // Show the window window.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("a"); component.addFocusListener(new MyFocusListener()); JFrame f = new JFrame(); f.add(component);//from w ww . j av a 2 s . c o m f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { Icon icon = new ImageIcon("dog.jpg"); JButton button = new JButton(icon); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.addTab("Tab Label", new JButton("button")); int index = pane.getTabCount() - 1; int keycode = KeyEvent.VK_L; pane.setMnemonicAt(index, keycode);// w w w . j a va2 s .c o m }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); JPanel centeredPanel = new JPanel(); centeredPanel.add(new JButton("one")); centeredPanel.add(new JButton("two")); f.getContentPane().add(centeredPanel); f.pack();/*w ww.j a v a2 s. co m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("a"); Set set = new HashSet(component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F2")); component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("Button"); component.getInputMap().put(KeyStroke.getKeyStroke("F2"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("control A"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("shift F2"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke('('), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("button3 F"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("typed x"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("released DELETE"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("shift UP"), "actionName"); component.getActionMap().put("actionName", new AbstractAction("actionName") { public void actionPerformed(ActionEvent evt) { System.out.println(evt); }/*from ww w . ja v a 2s . c o m*/ }); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); }/*from w ww. j ava 2 s . c om*/ }); ItemListener[] lis = jb.getItemListeners(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }