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[] args) { JPanel gui = new JPanel(new BorderLayout(5, 5)); int sz = 4;//from www . ja v a 2 s . c om Container content = new JPanel(new GridLayout(sz, 0, 2, 2)); for (int f = 0; f < sz * sz; f++) { content.add(new JButton()); } gui.add(content, BorderLayout.CENTER); Container info = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 5)); info.add(new JLabel("Flow")); info.add(new JLabel("Layout")); gui.add(info, BorderLayout.PAGE_START); gui.add(new JLabel("Label"), BorderLayout.LINE_END); JOptionPane.showMessageDialog(null, gui); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JEditorPane Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane editor = new JEditorPane("text/html", "<H3>Help</H3><center>www.java2s.com</center><li>One<li><i>Two</i><li><u>Three</u>"); editor.setEditable(false);//from ww w.j a va2 s.c o m JScrollPane scrollPane = new JScrollPane(editor); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:JScrollPaneViewport.java
public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Label"); label.setPreferredSize(new Dimension(1000, 1000)); JScrollPane jScrollPane = new JScrollPane(); jScrollPane.setViewportView(label);//from w w w. j a v a 2s. c om frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { final String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Multi-Columns"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList columns = new JList(labels); columns.setLayoutOrientation(JList.HORIZONTAL_WRAP); columns.setVisibleRowCount(3);/* w w w . j a va 2 s . co m*/ JScrollPane sp = new JScrollPane(columns); frame.add(sp, BorderLayout.CENTER); frame.setSize(300, 200); 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);/* ww w . j av a2 s. c o m*/ 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:AnimationTester.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ArrayComponent panel = new ArrayComponent(); frame.add(panel, BorderLayout.CENTER); frame.setSize(800, 300);//w w w . j av a 2 s .c o m frame.setVisible(true); Double[] values = new Double[100]; for (int i = 0; i < values.length; i++) values[i] = Math.random() * panel.getHeight(); final Sorter sorter = new Sorter(values, panel); Thread sorterThread = new Thread(sorter); sorterThread.start(); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setPreferredSize(new Dimension(400, 100)); JDesktopPane dtp = new JDesktopPane(); gui.add(dtp, BorderLayout.CENTER); JButton newFrame = new JButton("Add Frame"); ActionListener listener = new ActionListener() { private int disp = 10; @Override/*from www . ja v a 2s .c o m*/ public void actionPerformed(ActionEvent e) { JInternalFrame jif = new JInternalFrame(); dtp.add(jif); jif.setLocation(disp, disp); jif.setSize(100, 100); disp += 10; jif.setVisible(true); } }; newFrame.addActionListener(listener); gui.add(newFrame, BorderLayout.PAGE_START); JFrame f = new JFrame(); f.add(gui); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); 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.setLayout(new BorderLayout()); frame.add(new JLabel("Hit Escape to exit full screen", JLabel.CENTER), BorderLayout.CENTER); frame.setSize(300, 300);/*from w ww . j av a2s . c om*/ KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke("ESCAPE"); Action escapeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .setFullScreenWindow(null); } }; frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeKeyStroke, "ESCAPE"); frame.getRootPane().getActionMap().put("ESCAPE", escapeAction); GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); }
From source file:BoxSample.java
public static void main(String args[]) { JFrame verticalFrame = new JFrame("Vertical"); verticalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box verticalBox = Box.createVerticalBox(); verticalBox.add(new JLabel("Top")); verticalBox.add(new JTextField("Middle")); verticalBox.add(new JButton("Bottom")); verticalFrame.add(verticalBox, BorderLayout.CENTER); verticalFrame.setSize(150, 150);/* ww w . j a v a 2 s . c o m*/ verticalFrame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JTable Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rows[][] = { { "A", "Name 1", "38.94" }, { "B", "Name 2", "7.70" }, { "C", "Name 3", "112.65" } }; Object columns[] = { "Symbol", "Name", "Price" }; JTable table = new JTable(rows, columns); JScrollPane scrollPane = new JScrollPane(table); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200);/* w w w .ja v a2 s .c o m*/ f.setVisible(true); }