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: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"); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5);//from ww w .j a v a 2 s . com 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"); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5);/*from w ww . jav a2 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"); System.out.println(model.getElementAt(1)); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Key Text Sample"); KeyTextComponent keyTextComponent = new KeyTextComponent(); final JTextField textField = new JTextField(); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String keyText = actionEvent.getActionCommand(); textField.setText(keyText);/*from www . j a v a 2s . c o m*/ } }; keyTextComponent.addActionListener(actionListener); frame.add(keyTextComponent, BorderLayout.CENTER); frame.add(textField, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame("Test"); KeyboardFocusManager.getCurrentKeyboardFocusManager().addVetoableChangeListener("focusedWindow", new VetoableChangeListener() { private boolean gained = false; @Override//from www. j a va 2 s . c o m public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { if (evt.getNewValue() == frame) { gained = true; } if (gained && evt.getNewValue() != frame) { frame.dispose(); } } }); frame.add(new JTextField(10), BorderLayout.NORTH); frame.add(new JTextField(10), BorderLayout.SOUTH); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:ActiveSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Active Example"); UIManager.put(LABEL_FACTORY, new ActiveLabel()); final JPanel panel = new JPanel(); JButton button = new JButton("Get"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JLabel label = (JLabel) UIManager.get(LABEL_FACTORY); panel.add(label);//from w w w. ja va2 s . co m panel.revalidate(); } }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(200, 200); frame.setVisible(true); }
From source file:MovingIconTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JButton b;//from w w w.j ava 2 s. c o m Icon icon = new PieIcon(Color.red); b = new JButton("Default", icon); contentPane.add(b, BorderLayout.NORTH); b = new JButton("Text Left", icon); b.setHorizontalTextPosition(JButton.LEFT); contentPane.add(b, BorderLayout.SOUTH); b = new JButton("Text Up", icon); b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.TOP); contentPane.add(b, BorderLayout.EAST); b = new JButton("Text Down", icon); b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.BOTTOM); contentPane.add(b, BorderLayout.WEST); b = new JButton("Align Bottom Left", icon); b.setHorizontalAlignment(JButton.LEFT); b.setVerticalAlignment(JButton.BOTTOM); contentPane.add(b, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:Main.java
public static void main(final String args[]) { Vector<String> vec = new Vector<String>(); vec.add("a"); vec.add("b"); vec.add("c"); final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(vec); 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 va 2s . co 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"); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JTextPane codearea = new JTextPane(); JScrollPane scroll;/*from w w w. j a va 2s . co m*/ scroll = new JScrollPane(codearea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setPreferredSize(new Dimension(300, 300)); JPanel panel = new JPanel(new BorderLayout()); panel.add(scroll, BorderLayout.CENTER); JButton comp = new JButton("Print text"); comp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(codearea.getText()); } }); panel.add(comp, BorderLayout.SOUTH); frame.getContentPane().add(panel); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:TryBorderLayout.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Border Layout"); aWindow.setBounds(30, 30, 300, 300); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BorderLayout border = new BorderLayout(); // Create a layout manager Container content = aWindow.getContentPane(); // Get the content pane content.setLayout(border); // Set the container layout mgr EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border // Now add five JButton components and set their borders JButton button;/*from ww w. j a v a2 s . c om*/ content.add(button = new JButton("EAST"), BorderLayout.EAST); button.setBorder(edge); content.add(button = new JButton("WEST"), BorderLayout.WEST); button.setBorder(edge); content.add(button = new JButton("NORTH"), BorderLayout.NORTH); button.setBorder(edge); content.add(button = new JButton("SOUTH"), BorderLayout.SOUTH); button.setBorder(edge); content.add(button = new JButton("CENTER"), BorderLayout.CENTER); button.setBorder(edge); aWindow.setVisible(true); // Display the window }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("My Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border border = new BlackWhiteBorder(); JButton helloButton = new JButton("Hello"); helloButton.setBorder(border);//from w w w . ja v a 2 s . c o m JButton braveButton = new JButton("Brave New"); braveButton.setBorder(border); braveButton.setEnabled(false); JButton worldButton = new JButton("World"); worldButton.setBorder(border); Container contentPane = frame.getContentPane(); contentPane.add(helloButton, BorderLayout.NORTH); contentPane.add(braveButton, BorderLayout.CENTER); contentPane.add(worldButton, BorderLayout.SOUTH); frame.setSize(300, 100); frame.setVisible(true); }