List of usage examples for java.awt BorderLayout CENTER
String CENTER
To view the source code for java.awt BorderLayout CENTER.
Click Source Link
From source file:Main.java
public static void main(String[] arg) throws Exception { Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); Robot robot = new Robot(); BufferedImage image = robot/*from w w w . ja v a 2 s .c om*/ .createScreenCapture(new Rectangle(0, 0, (int) screenDim.getWidth(), (int) screenDim.getHeight())); JWindow window = new JWindow(new JFrame()); window.getContentPane().setLayout(new BorderLayout()); window.getContentPane().add(BorderLayout.CENTER, new JLabel(new ImageIcon(image))); window.pack(); window.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String[] ITEMS1 = { "one", "two", "three", "four", "five" }; String[] ITEMS2 = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; JPanel northPanel = new JPanel(); northPanel.add(new JCheckBox("Reminder")); northPanel.add(new JComboBox(ITEMS1)); northPanel.add(new JComboBox(ITEMS2)); JPanel p = new JPanel(new BorderLayout()); p.add(northPanel, BorderLayout.NORTH); p.add(new JScrollPane(new JTextArea(8, 30)), BorderLayout.CENTER); JFrame frame = new JFrame(); frame.getContentPane().add(p);/*from w w w .java 2s .c om*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); layout.layoutContainer(container);/*from w w w .j a v a2 s .co m*/ container.setLayout(layout); for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:JColorChooserSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JColorChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel("www.java2s.com", JLabel.CENTER); label.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); frame.add(label, BorderLayout.SOUTH); final JColorChooser colorChooser = new JColorChooser(label.getBackground()); colorChooser.setBorder(BorderFactory.createTitledBorder("Pick Foreground Color")); frame.add(colorChooser, BorderLayout.CENTER); frame.pack();//from w w w . j a v a 2 s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); layout.invalidateLayout(container);//from www . j a va 2 s . com container.setLayout(layout); for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); MyTableModel model = new MyTableModel(); JTable table = new JTable(model); table.setRowHeight(80);/*from www .ja va 2 s . c o m*/ table.getColumnModel().getColumn(0).setCellRenderer(new ImageRenderer()); JScrollPane pane = new JScrollPane(table); frame.getContentPane().add(BorderLayout.CENTER, pane); frame.setSize(500, 400); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); System.out.println(layout.getTarget()); container.setLayout(layout);// w w w. ja v a 2 s. c om for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); 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 a v a2 s. 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:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, true, true, true); palette.addPropertyChangeListener(new InternalFramePropertyChangeHandler()); palette.setBounds(350, 150, 100, 100); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);//from www. ja v a 2s . co m frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Password Example"); 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(KeyEvent.VK_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 v a 2 s . c o m*/ frame.setVisible(true); }