List of usage examples for java.awt Container setLayout
public void setLayout(LayoutManager mgr)
From source file:MnemonicSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Mnemonics"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); content.setLayout(new GridLayout(1, 0)); JButton button1 = new JButton("Warning"); button1.setMnemonic(KeyEvent.VK_W); content.add(button1);/*from w w w . j a va 2 s . com*/ JButton button2 = new JButton("Warning"); button2.setMnemonic(KeyEvent.VK_H); content.add(button2); frame.setSize(300, 200); frame.setVisible(true); }
From source file:AnEtchedBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Etched Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED); Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2, 5, 5)); contentPane.add(raisedButton);//from w w w . j av a 2 s. co m contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:ASoftBevelBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Soft Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new SoftBevelBorder(SoftBevelBorder.RAISED); Border loweredBorder = new SoftBevelBorder(SoftBevelBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(raisedButton);//from ww w .ja va2 s . c om contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("Soft Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new SoftBevelBorder(SoftBevelBorder.RAISED); Border loweredBorder = new SoftBevelBorder(SoftBevelBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(raisedButton);//w w w . j a va 2 s . c om contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); ButtonGroup group = new ButtonGroup(); JRadioButton option = new JRadioButton("French Fries", true); group.add(option);/*from www . j a v a2 s . c o m*/ contentPane.add(option); option = new JRadioButton("Onion Rings", false); group.add(option); contentPane.add(option); option = new JRadioButton("Ice Cream", false); group.add(option); contentPane.add(option); frame.setSize(200, 200); frame.show(); }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("Etched Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED); Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2, 5, 5)); contentPane.add(raisedButton);//from www .j ava 2s .c o m contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:AnEtchedBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Etched Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED); Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2, 5, 5)); contentPane.add(raisedButton);/* w w w. j av a 2 s.c o m*/ contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:ASoftBevelBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Soft Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new SoftBevelBorder(SoftBevelBorder.RAISED); Border loweredBorder = new SoftBevelBorder(SoftBevelBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(raisedButton);/*from w w w . j ava 2 s . c o m*/ contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:AlignmentSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); content.setLayout(new GridLayout(0, 1)); JTextField textField = new JTextField("Left"); textField.setHorizontalAlignment(JTextField.LEFT); content.add(textField);/*from w w w . ja v a2s. c o m*/ textField = new JTextField("Center"); textField.setHorizontalAlignment(JTextField.CENTER); content.add(textField); textField = new JTextField("Right"); textField.setHorizontalAlignment(JTextField.RIGHT); content.add(textField); textField = new JTextField("Leading"); textField.setHorizontalAlignment(JTextField.LEADING); content.add(textField); textField = new JTextField("Trailing"); textField.setHorizontalAlignment(JTextField.TRAILING); content.add(textField); frame.pack(); frame.setSize(250, (int) frame.getSize().getHeight()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String title = "GridBagLayout"; JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); for (int y = 0; y < 3; y++) { for (int x = 0; x < 4; x++) { gbc.gridx = x;//from ww w.j a v a 2 s .com gbc.gridy = y; String text = "Button (" + x + ", " + y + ")"; contentPane.add(new JButton(text), gbc); } } frame.pack(); frame.setVisible(true); }