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:KeyTester.java
public static void main(String args[]) { String actionKey = "theAction"; JFrame f = new JFrame("Key Tester"); JButton jb1 = new JButton("<html><center>B<br>Focused/Typed"); JButton jb2 = new JButton("<html><center>Ctrl-C<br>Window/Pressed"); JButton jb3 = new JButton("<html><center>Shift-D<br>Ancestor/Released"); Container pane = f.getContentPane(); pane.add(jb1, BorderLayout.NORTH); pane.add(jb2, BorderLayout.CENTER); pane.add(jb3, BorderLayout.SOUTH); KeyStroke stroke = KeyStroke.getKeyStroke("typed B"); Action action = new MyActionListener("Action Happened"); // Defaults to JComponent.WHEN_FOCUSED map InputMap inputMap = jb1.getInputMap(); inputMap.put(stroke, actionKey);//from w w w.j av a2 s. com ActionMap actionMap = jb1.getActionMap(); actionMap.put(actionKey, action); stroke = KeyStroke.getKeyStroke("ctrl C"); action = new MyActionListener("Action Didn't Happen"); inputMap = jb2.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(stroke, actionKey); actionMap = jb2.getActionMap(); actionMap.put(actionKey, action); stroke = KeyStroke.getKeyStroke("shift released D"); action = new MyActionListener("What Happened?"); inputMap = jb3.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(stroke, actionKey); actionMap = jb3.getActionMap(); actionMap.put(actionKey, action); f.setSize(200, 200); f.show(); }
From source file:SamplePopup.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Ask"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); Object response = JOptionPane.showInputDialog(source, "Where would you like to go to lunch?", "Select a Destination", JOptionPane.QUESTION_MESSAGE, null, new String[] { "A", "B", "C", "D", "E" }, "B"); System.out.println("Response: " + response); }/*from w w w. j a v a 2s . co m*/ }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("A"); model.addElement("C"); model.addElement("D"); model.addElement("A"); model.removeElement("A"); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5);//from w ww. j a v a 2 s. c o m comboBox1.setEditable(true); frame.add(comboBox1, BorderLayout.NORTH); JList<String> jlist = new JList<String>(model); JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); JButton button = new JButton("Add"); frame.add(button, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { model.addElement("a"); model.insertElementAt("Z", 0); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("A"); model.addElement("C"); model.addElement("D"); model.addElement("A"); model.removeElementAt(1);//w w w .j av a 2 s . co m JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5); comboBox1.setEditable(true); frame.add(comboBox1, BorderLayout.NORTH); JList<String> jlist = new JList<String>(model); JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); JButton button = new JButton("Add"); frame.add(button, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { model.addElement("a"); model.insertElementAt("Z", 0); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("A"); model.addElement("C"); model.addElement("D"); model.addElement("A"); model.removeAllElements();/*from w w w . j a v a 2s .c o m*/ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5); comboBox1.setEditable(true); frame.add(comboBox1, BorderLayout.NORTH); JList<String> jlist = new JList<String>(model); JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); JButton button = new JButton("Add"); frame.add(button, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { model.addElement("a"); model.insertElementAt("Z", 0); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("A"); model.addElement("C"); model.addElement("D"); model.addElement("A"); model.setSelectedItem("C"); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5);//from w w w.j a v a 2 s . c om comboBox1.setEditable(true); frame.add(comboBox1, BorderLayout.NORTH); JList<String> jlist = new JList<String>(model); JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); JButton button = new JButton("Add"); frame.add(button, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { model.addElement("a"); model.insertElementAt("Z", 0); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:SamplePopup.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Ask"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); Object response = JOptionPane.showInputDialog(source, "Where would you like to go to lunch?", "Select a Destination", JOptionPane.QUESTION_MESSAGE, null, new String[] { "A", "B", "C", "D", "E" }, "McDonalds"); System.out.println("Response: " + response); }/* w w w .ja v a2 s. c o m*/ }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); 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); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from w ww .j a v a2 s.com*/ DefaultListModel model = new DefaultListModel(); model.ensureCapacity(100); for (int i = 0; i < 100; i++) { model.addElement(Integer.toString(i)); } JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); JList jlist2 = new JList(model); jlist2.setVisibleRowCount(4); jlist2.setFixedCellHeight(12); jlist2.setFixedCellWidth(200); JScrollPane scrollPane2 = new JScrollPane(jlist2); frame.add(scrollPane2, BorderLayout.CENTER); JList jlist3 = new JList(labels); jlist3.setVisibleRowCount(4); frame.add(jlist3, BorderLayout.SOUTH); frame.setSize(300, 350); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame jframe = new JFrame(); jframe.setSize(500, 200);//from w w w .j a v a 2s. com jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane jTextPane = new JTextPane(); jTextPane.setEditorKit(new HTMLEditorKit()); JButton btn = new JButton("Print"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { jTextPane.setContentType("text/html"); boolean done = jTextPane.print(); if (done) { System.out.println("Printing is done"); } else { System.out.println("Error while printing"); } } catch (Exception pex) { pex.printStackTrace(); } } }); jframe.add(btn, BorderLayout.SOUTH); jframe.add(jTextPane); jframe.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { String title = (args.length == 0 ? "CheckBox Sample" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(0, 1)); Border border = BorderFactory.createTitledBorder("Pizza Toppings"); panel.setBorder(border);//from w ww .jav a 2 s .c o m JCheckBox check = new JCheckBox("Anchovies"); panel.add(check); check = new JCheckBox("Garlic"); panel.add(check); check = new JCheckBox("Onions"); panel.add(check); check = new JCheckBox("Pepperoni"); panel.add(check); check = new JCheckBox("Spinach"); panel.add(check); JButton button = new JButton("Submit"); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }