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 { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);/*from w ww . j a v a 2 s. co m*/ JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.VERTICAL; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JFrame frame = new JFrame(); JButton component1 = new JButton("1"); JButton component2 = new JButton("2"); JButton component3 = new JButton("3"); frame.setLayout(new FlowLayout()); frame.add(component1);/*from w ww. j a v a 2s .c o m*/ frame.add(component2); frame.add(component3); frame.pack(); frame.setVisible(true); System.out.println(findPrevFocus().getName()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//from ww w . ja v a 2s. c om JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//from www . j a va 2s . c o m JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JFrame frame = new JFrame(); JButton component1 = new JButton("1"); JButton component2 = new JButton("2"); JButton component3 = new JButton("3"); frame.setLayout(new FlowLayout()); frame.add(component1);//from w ww. j a v a 2 s . c om frame.add(component2); frame.add(component3); frame.pack(); frame.setVisible(true); System.out.println(findNextFocus().getName()); }
From source file:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent leftButton = new JButton("Left"); JComponent rightButton = new JButton("Right"); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setLeftComponent(leftButton); splitPane.setRightComponent(rightButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);//from w w w. j ava 2 s.c om horizontalFrame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//w w w. j a va2s. c o m JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); // Make the component on stretchable gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(null);/*from w w w. j a v a 2s . c o m*/ JButton b1 = new JButton("Button"); JButton b2 = new JButton("2"); contentPane.add(b1); contentPane.add(b2); b1.setBounds(10, 10, 100, 20); b2.setBounds(120, 10, 150, 40); frame.setBounds(0, 0, 350, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent topButton = new JButton("Left"); JComponent bottomButton = new JButton("Right"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);// www . ja v a2 s .co m horizontalFrame.setVisible(true); splitPane.setDividerLocation(0.5); }
From source file:Main.java
public static void main(String[] args) { final JTextPane pane = new JTextPane(); pane.setText("Some text"); JButton buttonButton = new JButton("Insert label"); buttonButton.addActionListener(e -> { JLabel label = new JLabel("label"); label.setAlignmentY(0.85f);// ww w . j a va2 s .co m pane.insertComponent(label); }); JPanel panel = new JPanel(new BorderLayout()); panel.add(buttonButton, BorderLayout.SOUTH); panel.add(pane, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setSize(400, 200); frame.setVisible(true); }