List of usage examples for java.awt BorderLayout WEST
String WEST
To view the source code for java.awt BorderLayout WEST.
Click Source Link
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);/*from ww w . jav a 2 s . c o m*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); textField.setText("Loooooooooooooooooooooooooooooooooooooooooooooooooooooooong"); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); System.out.println("extent:" + extent); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TestPane center = new TestPane(100, 100); frame.add(center);/*from w w w.j a va 2 s . com*/ frame.add(new TestPane(100, 50), BorderLayout.NORTH); frame.add(new TestPane(100, 50), BorderLayout.SOUTH); frame.add(new TestPane(50, 100), BorderLayout.EAST); frame.add(new TestPane(50, 100), BorderLayout.WEST); System.out.println("Size beofre pack = " + frame.getSize() + "; " + center.getSize()); frame.pack(); System.out.println("Size after pack = " + frame.getSize() + "; " + center.getSize()); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); textField.setHorizontalAlignment(JTextField.CENTER); label.setLabelFor(textField);/*from www. j a v a 2s . co m*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Tree Lines"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box box = Box.createHorizontalBox(); JTree tree1 = new JTree(); JScrollPane scrollPane1 = new JScrollPane(tree1); tree1.setAutoscrolls(true);//from w w w . j av a2s . co m JTree tree2 = new JTree(); tree2.putClientProperty("JTree.lineStyle", "None"); JScrollPane scrollPane2 = new JScrollPane(tree2); box.add(scrollPane1, BorderLayout.WEST); box.add(scrollPane2, BorderLayout.EAST); frame.add(box, BorderLayout.CENTER); frame.setSize(300, 240); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel userPanel = new JPanel(new BorderLayout()); JLabel userLabel = new JLabel("Username: "); userLabel.setDisplayedMnemonic(KeyEvent.VK_U); JTextField userTextField = new JTextField(); userLabel.setLabelFor(userTextField); userPanel.add(userLabel, BorderLayout.WEST); userPanel.add(userTextField, BorderLayout.CENTER); JPanel passPanel = new JPanel(new BorderLayout()); JLabel passLabel = new JLabel("Password: "); passLabel.setDisplayedMnemonic('p'); JPasswordField passTextField = new JPasswordField(); passLabel.setLabelFor(passTextField); passPanel.add(passLabel, BorderLayout.WEST); passPanel.add(passTextField, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add(userPanel, BorderLayout.NORTH); panel.add(passPanel, BorderLayout.SOUTH); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150);/*w w w . j a v a 2 s .com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel userPanel = new JPanel(new BorderLayout()); JLabel userLabel = new JLabel("Username: "); userLabel.setDisplayedMnemonic(KeyEvent.VK_U); JTextField userTextField = new JTextField(); userLabel.setLabelFor(userTextField); userPanel.add(userLabel, BorderLayout.WEST); userPanel.add(userTextField, BorderLayout.CENTER); System.out.println(userLabel.getDisplayedMnemonicIndex()); JPanel passPanel = new JPanel(new BorderLayout()); JLabel passLabel = new JLabel("Password: "); passLabel.setDisplayedMnemonic('p'); JPasswordField passTextField = new JPasswordField(); passLabel.setLabelFor(passTextField); passPanel.add(passLabel, BorderLayout.WEST); passPanel.add(passTextField, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add(userPanel, BorderLayout.NORTH); panel.add(passPanel, BorderLayout.SOUTH); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150);// w w w . j ava 2 s.com frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel userPanel = new JPanel(new BorderLayout()); JLabel userLabel = new JLabel("Username: "); userLabel.setDisplayedMnemonic(KeyEvent.VK_U); JTextField userTextField = new JTextField(); userLabel.setLabelFor(userTextField); userPanel.add(userLabel, BorderLayout.WEST); userPanel.add(userTextField, BorderLayout.CENTER); System.out.println(userLabel.getDisplayedMnemonic()); JPanel passPanel = new JPanel(new BorderLayout()); JLabel passLabel = new JLabel("Password: "); passLabel.setDisplayedMnemonic('p'); JPasswordField passTextField = new JPasswordField(); passLabel.setLabelFor(passTextField); passPanel.add(passLabel, BorderLayout.WEST); passPanel.add(passTextField, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add(userPanel, BorderLayout.NORTH); panel.add(passPanel, BorderLayout.SOUTH); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150);/* w w w . j a v a 2 s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel userPanel = new JPanel(new BorderLayout()); JLabel userLabel = new JLabel("Username: "); userLabel.setDisplayedMnemonic(KeyEvent.VK_U); JTextField userTextField = new JTextField(); userLabel.setLabelFor(userTextField); userPanel.add(userLabel, BorderLayout.WEST); userPanel.add(userTextField, BorderLayout.CENTER); System.out.println(userLabel.getHorizontalAlignment()); JPanel passPanel = new JPanel(new BorderLayout()); JLabel passLabel = new JLabel("Password: "); passLabel.setDisplayedMnemonic('p'); JPasswordField passTextField = new JPasswordField(); passLabel.setLabelFor(passTextField); passPanel.add(passLabel, BorderLayout.WEST); passPanel.add(passTextField, BorderLayout.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add(userPanel, BorderLayout.NORTH); panel.add(passPanel, BorderLayout.SOUTH); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150);//from w w w . j a va 2 s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("This is BOX LAYOUT"); JPanel panel1 = new JPanel(); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel1.setBackground(Color.yellow); JPanel panel2 = new JPanel(); panel2.setLayout(new FlowLayout()); panel2.setBackground(Color.ORANGE); for (int i = 0; i < 5; i++) panel1.add(new JCheckBox("CheckBox " + (i + 1))); f.add(panel1, BorderLayout.WEST); f.add(panel2, BorderLayout.CENTER); f.setVisible(true);/*from w ww. j a v a 2 s.c o m*/ f.setSize(300, 300); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) { JToolBar toolbar = new JToolBar(JToolBar.VERTICAL); JButton selectb = new JButton(new ImageIcon("select.gif")); JButton freehandb = new JButton(new ImageIcon("freehand.gif")); JButton shapeedb = new JButton(new ImageIcon("shapeed.gif")); JButton penb = new JButton(new ImageIcon("pen.gif")); toolbar.add(selectb);/*ww w . ja v a2 s . c o m*/ toolbar.add(freehandb); toolbar.add(shapeedb); toolbar.add(penb); JFrame f = new JFrame(); f.add(toolbar, BorderLayout.WEST); f.setSize(250, 350); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }