List of usage examples for javax.swing BoxLayout X_AXIS
int X_AXIS
To view the source code for javax.swing BoxLayout X_AXIS.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component1 = new JButton(); Box box = new Box(BoxLayout.X_AXIS); int width = 10; box.add(Box.createHorizontalStrut(width)); box.add(component1);//ww w . j a v a2s. c o m }
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);//from ww w .j a v a 2 s.co m box.add(Box.createGlue()); box.add(component2); }
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 = Box.createHorizontalBox(); // Add components box.add(component1);/*from w ww .ja v a2 s .c om*/ box.add(component2); }
From source file:AlignY.java
public static void main(String args[]) { JFrame frame = new JFrame("Y Alignment"); JPanel contentPane = (JPanel) frame.getContentPane(); BoxLayout layout = new BoxLayout(contentPane, BoxLayout.X_AXIS); contentPane.setLayout(layout);// www .ja v a 2 s .c o m JButton button = new JButton("0.0"); button.setAlignmentY(Component.TOP_ALIGNMENT); contentPane.add(button); button = new JButton("1.0"); button.setAlignmentY(Component.BOTTOM_ALIGNMENT); contentPane.add(button); button = new JButton("0.5"); button.setAlignmentY(Component.CENTER_ALIGNMENT); contentPane.add(button); frame.setSize(200, 100); frame.show(); }
From source file:BoxLayoutDemo.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); LayoutManager layout = new BoxLayout(panel, BoxLayout.X_AXIS); panel.setLayout(layout);/*from w ww . j a va 2s. com*/ panel.add(new JLabel("a")); panel.add(new JLabel("b")); panel.add(new JLabel("c")); panel.add(new JLabel("d")); panel.add(new JLabel("e")); panel.add(new JLabel("f")); frame.add(panel); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("BoxLayout Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JPanel hPanel = new JPanel(); BoxLayout boxLayout = new BoxLayout(hPanel, BoxLayout.X_AXIS); hPanel.setLayout(boxLayout);/*from w w w. ja v a2 s . co m*/ for (int i = 1; i <= 5; i++) { hPanel.add(new JButton("Button " + i)); } contentPane.add(hPanel, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS); container.setLayout(layout);/*from w ww. j a v a 2 s.c o m*/ for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); button.setAlignmentX(Component.BOTTOM_ALIGNMENT); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS); container.setLayout(layout);/*w ww .jav a 2s . com*/ for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); button.setAlignmentX(Component.TOP_ALIGNMENT); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:TwoButtons.java
public static void main(String[] args) { JFrame f = new JFrame(); JPanel basic = new JPanel(); basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS)); f.add(basic);//from www .j av a 2 s .c o m basic.add(Box.createVerticalGlue()); JPanel bottom = new JPanel(); bottom.setAlignmentX(1f); bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS)); JButton ok = new JButton("OK"); JButton close = new JButton("Close"); bottom.add(ok); bottom.add(Box.createRigidArea(new Dimension(5, 0))); bottom.add(close); bottom.add(Box.createRigidArea(new Dimension(15, 0))); basic.add(bottom); basic.add(Box.createRigidArea(new Dimension(0, 15))); f.setSize(300, 250); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:BoxSample.java
public static void main(String args[]) { JButton button;/*from w ww. j a va2 s . c o m*/ Vector buttons = new Vector(); Dimension dim; JFrame frame = new JFrame("Box Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); JPanel topLeft = new JPanel(); topLeft.setLayout(new BoxLayout(topLeft, BoxLayout.X_AXIS)); topLeft.add(button = new JButton("One")); buttons.add(button); changeBoth(button); topLeft.add(button = new JButton("Two")); buttons.add(button); changeBoth(button); changeWidth(topLeft); JPanel bottomLeft = new JPanel(); bottomLeft.setLayout(new BoxLayout(bottomLeft, BoxLayout.X_AXIS)); bottomLeft.add(button = new JButton("Six")); buttons.add(button); changeBoth(button); bottomLeft.add(button = new JButton("Seven")); buttons.add(button); changeBoth(button); changeWidth(bottomLeft); JPanel left = new JPanel(); left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS)); left.add(topLeft); left.add(button = new JButton("Four")); buttons.add(button); changeBoth(button); left.add(bottomLeft); changeBoth(left); JPanel right = new JPanel(); right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS)); right.add(button = new JButton("Three")); buttons.add(button); changeWidth(button); right.add(button = new JButton("Five")); buttons.add(button); changeBoth(button); changeBoth(right); contentPane.add(left); contentPane.add(right); tweak(buttons); frame.pack(); frame.setVisible(true); }