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(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox = new JComboBox<>(new String[] { "Something", "Stuff", "Beep" }); JButton add = new JButton("Add item"); add.addActionListener(new ActionListener() { @Override// w w w .j a va 2s .co m public void actionPerformed(ActionEvent e) { comboBox.addItem("Item"); } }); frame.add(comboBox); frame.add(add, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("LabelFor Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Username"); JTextField textField = new JTextField(); label.setDisplayedMnemonic(KeyEvent.VK_U); label.setLabelFor(textField);/* w w w . j a va 2 s . c o m*/ Container box = Box.createHorizontalBox(); box.add(label); box.add(textField); frame.add(box, BorderLayout.NORTH); frame.add(new JButton("Submit"), BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:SpinnerNumberEditorSample2.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25); JSpinner spinner = new JSpinner(model); JComponent editor = new JSpinner.NumberEditor(spinner, "#,##0.###"); spinner.setEditor(editor);//w ww . jav a 2 s .c o m JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:ComboBoxSample.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; String title = (args.length == 0 ? "Example JComboBox" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentpane = frame.getContentPane(); JComboBox comboBox1 = new JComboBox(labels); comboBox1.setMaximumRowCount(5);//ww w . j a v a 2 s . c o m contentpane.add(comboBox1, BorderLayout.NORTH); JComboBox comboBox2 = new JComboBox(labels); comboBox2.setEditable(true); contentpane.add(comboBox2, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); p.setOpaque(true);/*from w w w .j a va 2 s.c o m*/ p.setLayout(new FlowLayout()); p.add(good); f.add(p, BorderLayout.CENTER); f.add(resultLabel, BorderLayout.SOUTH); good.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { resultLabel.setText("Working . . ."); good.setEnabled(false); Thread worker = new Thread() { public void run() { try { Thread.sleep(5000); } catch (InterruptedException ex) { } SwingUtilities.invokeLater(new Runnable() { public void run() { resultLabel.setText("Ready"); good.setEnabled(true); } }); } }; worker.start(); // So we don't hold up the dispatch thread. } }); f.setSize(300, 100); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400);/* ww w. j a v a 2s. co m*/ JDialog dialog = new JDialog(frame, "Dialog", true); JPanel mainGui = new JPanel(new BorderLayout()); mainGui.setBorder(new EmptyBorder(20, 20, 20, 20)); mainGui.add(new JLabel("Contents go here"), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout()); mainGui.add(buttonPanel, BorderLayout.SOUTH); JButton close = new JButton("Close"); close.addActionListener(e -> dialog.setVisible(false)); buttonPanel.add(close); frame.setVisible(true); dialog.setContentPane(mainGui); dialog.pack(); dialog.setVisible(true); }
From source file:Main.java
public static void main(String... args) { JFrame frame = new JFrame(); JSpinner jspinner = makeDigitsOnlySpinnerUsingDocumentFilter(); frame.getContentPane().add(jspinner, BorderLayout.CENTER); frame.getContentPane().add(new JButton("just another widget"), BorderLayout.SOUTH); frame.pack();//from w w w. j a v a 2s. com 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(); label.setLabelFor(textField);/*from ww w .j a va2 s. com*/ 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.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); 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);// www.j ava 2 s .c om panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); JTextPane textPane = new JTextPane(); JButton button = new JButton("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.setLayout(new BorderLayout()); panel.setPreferredSize(new Dimension(200, 200)); panel.add(textPane, BorderLayout.CENTER); panel.add(button, BorderLayout.SOUTH); textPane.addStyle("myStyle", null); button.addActionListener(e -> {/*from w w w . ja v a 2 s . c om*/ StyledDocument doc = textPane.getStyledDocument(); int start = textPane.getSelectionStart(); int end = textPane.getSelectionEnd(); if (start == end) { return; } if (start > end) { int life = start; start = end; end = life; } Style style = textPane.getStyle("myStyle"); if (StyleConstants.isBold(style)) { StyleConstants.setBold(style, false); } else { StyleConstants.setBold(style, true); } doc.setCharacterAttributes(start, end - start, style, false); }); frame.add(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }