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[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }//from ww w. j a v a2s .co m }); System.out.println(jb.getAction()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); String label = "Tab Label"; String tooltip = "Tool Tip Text"; pane.addTab(label, null, new JButton("Button"), tooltip); int index = pane.getTabCount() - 1; tooltip = pane.getToolTipTextAt(index); tooltip = "New Tool Tip Text"; pane.setToolTipTextAt(index, tooltip); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }// w w w . java 2 s . co m }); ActionListener[] lis = jb.getActionListeners(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from ww w . j a v a2s . c o m }); jb.setVerticalAlignment(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from w ww.j a v a 2s. c o m }); jb.setText("new text"); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }/* www .ja v a 2 s . co m*/ }); jb.setVerticalTextPosition(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:SettingDefaultButton.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button4 = new JButton("AAA"); frame.add(button4, "Center"); frame.add(new JButton("BBB"), "South"); JRootPane rootPane = frame.getRootPane(); rootPane.setDefaultButton(button4);/*from w ww.j ava 2 s . c om*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.setIcon(new MyIcon()); jb.setIconTextGap(50);//from w w w .jav a2s . c o m JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:ComplexMessageDemo.java
public static void main(String[] a) { Object complexMsg[] = { "Above Message", new ImageIcon("yourFile.gif"), new JButton("Hello"), new JSlider(), new ImageIcon("yourFile.gif"), "Below Message" }; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage(complexMsg);//from w w w. ja va 2 s . co m optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }
From source file:ButtonTipTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Tool Tips"); Container contentPane = frame.getContentPane(); JButton b = new JButton("Button"); b.setToolTipText("Go Away"); contentPane.add(b, BorderLayout.NORTH); frame.setSize(300, 200);//from w ww . java2 s. com frame.show(); }