List of usage examples for java.awt BorderLayout SOUTH
String SOUTH
To view the source code for java.awt BorderLayout SOUTH.
Click Source Link
From source file:SpinnerTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Spinning"); Container contentPane = frame.getContentPane(); String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SpinnerModel model = new SpinnerListModel(months); JSpinner spinner = new JSpinner(model); contentPane.add(spinner, BorderLayout.NORTH); SpinnerDateModel model2 = new SpinnerDateModel(); model2.setCalendarField(Calendar.WEEK_OF_MONTH); JSpinner spinner2 = new JSpinner(model2); JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy"); spinner2.setEditor(editor2);/*from w w w . ja v a 2 s. c o m*/ frame.getContentPane().add(spinner2, BorderLayout.CENTER); SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5); JSpinner spinner3 = new JSpinner(model3); frame.getContentPane().add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 100); frame.show(); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Verifier Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textField1 = new JTextField(); JTextField textField2 = new JTextField(); JTextField textField3 = new JTextField(); InputVerifier verifier = new InputVerifier() { public boolean verify(JComponent comp) { boolean returnValue; JTextField textField = (JTextField) comp; try { Integer.parseInt(textField.getText()); returnValue = true;/*from w w w . j a va 2 s . co m*/ } catch (NumberFormatException e) { returnValue = false; } return returnValue; } }; textField1.setInputVerifier(verifier); textField3.setInputVerifier(verifier); Container contentPane = frame.getContentPane(); contentPane.add(textField1, BorderLayout.NORTH); contentPane.add(textField2, BorderLayout.CENTER); contentPane.add(textField3, BorderLayout.SOUTH); frame.setSize(300, 100); frame.setVisible(true); }
From source file:ElementSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Element Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); JButton button = new JButton("Show Elements"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Document document = textArea.getDocument(); ElementIterator iterator = new ElementIterator(document); Element element = iterator.first(); while (element != null) { System.out.println(element.getStartOffset()); element = iterator.next(); }/*from w w w . ja v a 2 s . c om*/ } }; button.addActionListener(actionListener); frame.add(scrollPane, BorderLayout.CENTER); frame.add(button, BorderLayout.SOUTH); frame.setSize(250, 250); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Element Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); JButton button = new JButton("Show Elements"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Document document = textArea.getDocument(); ElementIterator iterator = new ElementIterator(document); Element element = iterator.first(); while (element != null) { System.out.println(element.getStartOffset()); element = iterator.next(); }/* w w w . j a v a2 s . c o m*/ } }; button.addActionListener(actionListener); frame.add(scrollPane, BorderLayout.CENTER); frame.add(button, BorderLayout.SOUTH); frame.setSize(250, 250); 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);/*from ww w. j a va 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);/*ww w. j av a2 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.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);//from ww w. java 2 s. c om frame.setVisible(true); }
From source file:SizingSamples.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);// w w w .j a v a 2s . c om DefaultListModel model = new DefaultListModel(); model.ensureCapacity(1000); for (int i = 0; i < 100; i++) { for (int j = 0; j < 10; j++) { model.addElement(labels[j]); } } JScrollPane scrollPane1 = new JScrollPane(jlist1); contentPane.add(scrollPane1, BorderLayout.NORTH); JList jlist2 = new JList(model); jlist2.setVisibleRowCount(4); jlist2.setFixedCellHeight(12); jlist2.setFixedCellWidth(200); JScrollPane scrollPane2 = new JScrollPane(jlist2); contentPane.add(scrollPane2, BorderLayout.CENTER); JList jlist3 = new JList(labels); jlist3.setVisibleRowCount(4); contentPane.add(jlist3, BorderLayout.SOUTH); frame.setSize(300, 350); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Default Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textField = new JTextField(); frame.add(textField, BorderLayout.NORTH); JPanel panel = new JPanel(); JButton defaultButton = new JButton("Default Button"); defaultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println(actionEvent.getActionCommand() + " selected"); }// w w w . ja v a 2 s . co m }); panel.add(defaultButton); JButton otherButton = new JButton("Other Button"); otherButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println(actionEvent.getActionCommand() + " selected"); } }); panel.add(otherButton); frame.add(panel, BorderLayout.SOUTH); Keymap keymap = textField.getKeymap(); KeyStroke keystroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false); keymap.removeKeyStrokeBinding(keystroke); frame.getRootPane().setDefaultButton(defaultButton); frame.setSize(250, 150); frame.setVisible(true); }
From source file:FileSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JLabel directoryLabel = new JLabel(); contentPane.add(directoryLabel, BorderLayout.NORTH); final JLabel filenameLabel = new JLabel(); contentPane.add(filenameLabel, BorderLayout.SOUTH); final JButton button = new JButton("Open FileChooser"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component parent = (Component) actionEvent.getSource(); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setAccessory(new LabelAccessory(fileChooser)); FileView view = new JavaFileView(); fileChooser.setFileView(view); int status = fileChooser.showOpenDialog(parent); if (status == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); directoryLabel.setText(selectedFile.getParent()); filenameLabel.setText(selectedFile.getName()); } else if (status == JFileChooser.CANCEL_OPTION) { directoryLabel.setText(" "); filenameLabel.setText(" "); }//from w w w.java 2s .c om } }; button.addActionListener(actionListener); contentPane.add(button, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }