List of usage examples for javax.swing JFrame setLayout
public void setLayout(LayoutManager manager)
LayoutManager
. From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); JLabel label = new JLabel("User Name:", SwingConstants.RIGHT); JLabel label2 = new JLabel("Password:", SwingConstants.RIGHT); JTextField userNameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(); frame.add(label);/*from ww w. j a v a 2 s. c o m*/ frame.add(userNameField); frame.add(label2); frame.add(passwordField); frame.setSize(200, 70); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JSeparator Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new GridLayout(0, 1)); JLabel above = new JLabel("Above Separator"); f.add(above);/*from w ww .j av a 2 s. co m*/ JSeparator separator = new JSeparator(); f.add(separator); JLabel below = new JLabel("Below Separator"); f.add(below); f.setSize(300, 100); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextField tf = new JTextField("mm"); tf.setPreferredSize(tf.getPreferredSize()); tf.setText(""); JPanel pHacked = new JPanel(); pHacked.add(tf);/*from w w w . j a v a2s . c o m*/ JPanel pStock = new JPanel(); pStock.add(new JTextField(2)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new java.awt.GridLayout(0, 1)); frame.add(pHacked); frame.add(pStock); frame.setSize(150, 150); frame.setVisible(true); tf.requestFocus(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.pack();/*from w w w. j a va 2 s . c o m*/ frame.setVisible(true); System.out.println("Frame size = " + frame.getSize()); }
From source file:FormLayoutTester.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new FormLayout()); frame.add(new JLabel("A")); frame.add(new JTextField(15)); frame.add(new JLabel("AA")); frame.add(new JTextField(20)); frame.add(new JLabel("AAAA")); frame.add(new JTextField(10)); frame.add(new JLabel("AAAAAA")); frame.add(new JTextField(2)); frame.add(new JLabel("AAAAAAAA")); frame.add(new JTextField(5)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();/*from w w w. ja va 2 s .c o m*/ frame.setVisible(true); }
From source file:NoLayoutTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("NoLayout Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(null); JLabel label = new JLabel("First Name:"); label.setBounds(20, 20, 100, 20);/*from w w w . j av a 2s . c om*/ JTextField textField = new JTextField(); textField.setBounds(124, 25, 100, 20); frame.add(label); frame.add(textField); frame.setSize(300, 100); frame.setVisible(true); }
From source file:BasicArrowButtonSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Popup JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(0, 5)); frame.add(new BasicArrowButton(BasicArrowButton.EAST)); frame.add(new BasicArrowButton(BasicArrowButton.NORTH)); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH)); frame.add(new BasicArrowButton(BasicArrowButton.WEST)); frame.setSize(300, 200);/*from w ww . j a v a2 s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); JLabel label = new JLabel("User Name:", SwingConstants.RIGHT); JLabel label2 = new JLabel("Password:", SwingConstants.RIGHT); JTextField userNameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(); passwordField.setEchoChar('#'); frame.add(label);//w ww. j a va 2 s .com frame.add(userNameField); frame.add(label2); frame.add(passwordField); frame.setSize(200, 70); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new BorderLayout()); f.add(new TestPane()); f.pack();/* ww w. j av a2s . c o m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTabbedPane tp = new JTabbedPane(); tp.addTab("Dates", new JPanel()); tp.addTab("Deliveries", new JPanel()); tp.addTab("Exports", new JPanel()); tp.setTabComponentAt(0, new JLabel("Dates")); tp.setTabComponentAt(1, new JLabel("Deliveries")); tp.setTabComponentAt(2, new JLabel("Exports")); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(tp);/*from w ww. ja v a 2 s .c om*/ frame.pack(); frame.setVisible(true); }