List of usage examples for javax.swing Box createVerticalStrut
public static Component createVerticalStrut(int height)
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 ww w . j a v a 2 s . c o m 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.createVerticalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/* ww w . jav a2s . 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(Box.createRigidArea(new Dimension(20, 20))); rowOne.add(new JTextField()); Component rowTwo = Box.createVerticalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/*from ww w . j a v a 2s . c o m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box left = Box.createVerticalBox(); left.add(Box.createVerticalStrut(30)); ButtonGroup radioGroup = new ButtonGroup(); JRadioButton rbutton;// w w w . j a va 2s .c o m radioGroup.add(rbutton = new JRadioButton("Red")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Green")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Blue")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Yellow")); left.add(rbutton); left.add(Box.createGlue()); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(left, BorderLayout.CENTER); Box right = Box.createVerticalBox(); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Dashed")); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Thick")); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Rounded")); right.add(Box.createGlue()); JPanel rightPanel = new JPanel(new BorderLayout()); rightPanel.add(right, BorderLayout.CENTER); Box top = Box.createHorizontalBox(); top.add(leftPanel); top.add(Box.createHorizontalStrut(5)); top.add(rightPanel); Container content = aWindow.getContentPane(); content.setLayout(new BorderLayout()); content.add(top, BorderLayout.CENTER); BoxLayout box = new BoxLayout(content, BoxLayout.Y_AXIS); content.setLayout(box); content.add(top); aWindow.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Box Layout"); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box left = Box.createVerticalBox(); left.add(Box.createVerticalStrut(30)); ButtonGroup radioGroup = new ButtonGroup(); JRadioButton rbutton;/*from w w w . ja v a2 s . com*/ radioGroup.add(rbutton = new JRadioButton("Red")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Green")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Blue")); left.add(rbutton); left.add(Box.createVerticalStrut(30)); radioGroup.add(rbutton = new JRadioButton("Yellow")); left.add(rbutton); left.add(Box.createGlue()); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setBorder(new TitledBorder(new EtchedBorder(), "Line Color")); leftPanel.add(left, BorderLayout.CENTER); Box right = Box.createVerticalBox(); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Dashed")); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Thick")); right.add(Box.createVerticalStrut(30)); right.add(new JCheckBox("Rounded")); right.add(Box.createGlue()); JPanel rightPanel = new JPanel(new BorderLayout()); rightPanel.setBorder(new TitledBorder(new EtchedBorder(), "Line Properties")); rightPanel.add(right, BorderLayout.CENTER); Box top = Box.createHorizontalBox(); top.add(leftPanel); top.add(Box.createHorizontalStrut(5)); top.add(rightPanel); Container content = aWindow.getContentPane(); content.setLayout(new BorderLayout()); content.add(top, BorderLayout.CENTER); BoxLayout box = new BoxLayout(content, BoxLayout.Y_AXIS); content.setLayout(box); content.add(top); aWindow.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { int BTN_COUNT = 3; int VERT_GAP = 10; int EB_GAP = 5; float TITLE_SIZE = 36f; String TITLE_TEXT = "This is my Title"; JLabel titleLabel = new JLabel(TITLE_TEXT, SwingConstants.CENTER); titleLabel.setFont(titleLabel.getFont().deriveFont(TITLE_SIZE)); JPanel titlePanel = new JPanel(); titlePanel.add(titleLabel);/*from w w w. j av a 2s. c o m*/ JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 5, 0)); for (int i = 0; i < BTN_COUNT; i++) { JButton btn = new JButton("Button " + (i + 1)); buttonPanel.add(btn); } JTextArea textArea = new JTextArea(20, 30); JPanel mainPanel = new JPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(EB_GAP, EB_GAP, EB_GAP, EB_GAP)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS)); mainPanel.add(titlePanel); mainPanel.add(Box.createVerticalStrut(VERT_GAP)); mainPanel.add(buttonPanel); mainPanel.add(Box.createVerticalStrut(VERT_GAP)); mainPanel.add(new JScrollPane(textArea)); JFrame frame = new JFrame(); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
private static JPanel createLogin() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JLabel label = new JLabel("login panel."); label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f)); label.setAlignmentX(0.5f);/*from www . j a v a2 s. c o m*/ label.setBorder(new EmptyBorder(0, 20, 0, 20)); p.add(Box.createVerticalStrut(36)); p.add(label); p.add(Box.createVerticalStrut(144)); return p; }
From source file:Box2.java
public void init() { Box bv = Box.createVerticalBox(); for (int i = 0; i < 5; i++) { bv.add(new JButton("bv " + i)); bv.add(Box.createVerticalStrut(i * 10)); }// w w w . j a v a 2 s .co m Box bh = Box.createHorizontalBox(); for (int i = 0; i < 5; i++) { bh.add(new JButton("bh " + i)); bh.add(Box.createHorizontalStrut(i * 10)); } Container cp = getContentPane(); cp.add(BorderLayout.EAST, bv); cp.add(BorderLayout.SOUTH, bh); }
From source file:Main.java
public Main() { super("Demostrating BoxLayout"); final int SIZE = 3; Container c = getContentPane(); c.setLayout(new BorderLayout(30, 30)); Box boxes[] = new Box[4]; boxes[0] = Box.createHorizontalBox(); boxes[1] = Box.createVerticalBox(); boxes[2] = Box.createHorizontalBox(); boxes[3] = Box.createVerticalBox(); for (int i = 0; i < SIZE; i++) boxes[0].add(new JButton("boxes[0]: " + i)); for (int i = 0; i < SIZE; i++) { boxes[1].add(Box.createVerticalStrut(25)); boxes[1].add(new JButton("boxes[1]: " + i)); }// w ww . j a v a 2 s .c om for (int i = 0; i < SIZE; i++) { boxes[2].add(Box.createHorizontalGlue()); boxes[2].add(new JButton("boxes[2]: " + i)); } for (int i = 0; i < SIZE; i++) { boxes[3].add(Box.createRigidArea(new Dimension(12, 8))); boxes[3].add(new JButton("boxes[3]: " + i)); } JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); for (int i = 0; i < SIZE; i++) { panel.add(Box.createGlue()); panel.add(new JButton("panel: " + i)); } c.add(boxes[0], BorderLayout.NORTH); c.add(boxes[1], BorderLayout.EAST); c.add(boxes[2], BorderLayout.SOUTH); c.add(boxes[3], BorderLayout.WEST); c.add(panel, BorderLayout.CENTER); setSize(350, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
From source file:Main.java
public Main() { JFormattedTextField formattedField = null; try {//from w w w .j a v a 2s . co m MaskFormatter dateMask = new MaskFormatter("##/##/####"); formattedField = new JFormattedTextField(dateMask); } catch (ParseException ex) { System.out.println(ex); } formattedField.setColumns(10); formattedField.setInputVerifier(getInputVerifier()); JTextField field = new JTextField(10); format.setLenient(false); Box box = Box.createVerticalBox(); box.add(formattedField); box.add(Box.createVerticalStrut(10)); box.add(field); box.setBorder(new EmptyBorder(10, 10, 10, 10)); JFrame frame = new JFrame(); frame.add(box); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }