List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); JButton component2 = new JButton(); Box box = new Box(BoxLayout.X_AXIS); box.add(component1); box.add(Box.createGlue());// w ww . ja va 2 s.com box.add(component2); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Component rowTwo = Box.createHorizontalGlue(); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);//from w w w.j ava 2 s. c om f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = new Box(BoxLayout.Y_AXIS); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Component rowTwo = Box.createVerticalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/*from www .java 2s. com*/ f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Component rowTwo = Box.createHorizontalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/*from w ww . j a v a2 s .co m*/ f.setVisible(true); }
From source file:BoxSample.java
public static void main(String args[]) { JFrame verticalFrame = new JFrame("Vertical"); verticalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box verticalBox = Box.createVerticalBox(); verticalBox.add(new JLabel("Top")); verticalBox.add(new JTextField("Middle")); verticalBox.add(new JButton("Bottom")); verticalFrame.add(verticalBox, BorderLayout.CENTER); verticalFrame.setSize(150, 150);/*from w ww . ja va 2 s.c o m*/ verticalFrame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Component rowTwo = Box.createVerticalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);//ww w . ja v a 2 s. com f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Box rowTwo = Box.createHorizontalBox(); rowTwo.add(new JLabel("Password")); rowTwo.add(new JPasswordField()); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/*from ww w. j a v a2 s . co m*/ f.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JPasswordField Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Box rowTwo = Box.createHorizontalBox(); rowTwo.add(new JLabel("Password")); rowTwo.add(new JPasswordField()); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/*w w w. j a v a2s . co m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("BoxLayout with Glue"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); Box hBox = Box.createHorizontalBox(); hBox.add(new JButton("First")); hBox.add(new JButton("Previous")); hBox.add(Box.createHorizontalGlue()); hBox.add(new JButton("Next")); hBox.add(new JButton("Last")); contentPane.add(hBox, BorderLayout.SOUTH); frame.pack();// w w w. j av a2 s.c o m frame.setVisible(true); }
From source file:BoxSample.java
public static void main(String args[]) { JFrame horizontalFrame = new JFrame("Horizontal"); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box horizontalBox = Box.createHorizontalBox(); horizontalBox.add(new JLabel("Left")); horizontalBox.add(new JTextField("Middle")); horizontalBox.add(new JButton("Right")); horizontalFrame.add(horizontalBox, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);// w ww. ja v a 2 s . c o m horizontalFrame.setVisible(true); }