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 ui = new JPanel(new BorderLayout(2, 2)); ui.setBorder(new EmptyBorder(4, 4, 4, 4)); JPanel controls = new JPanel(new BorderLayout(2, 2)); ui.add(controls, BorderLayout.PAGE_START); String s = new String(Character.toChars(8594)); String[] items = { "Choice: right " + s + " arrow" }; JComboBox cb = new JComboBox(items); controls.add(cb, BorderLayout.CENTER); controls.add(new JButton("Button"), BorderLayout.LINE_END); JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JTextArea(4, 40), new JTextArea(4, 40)); ui.add(sp, BorderLayout.CENTER); JFrame f = new JFrame("Stretch Combo Layout"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(ui);//from w w w . j ava 2s. c o m f.pack(); f.setLocationByPlatform(true); f.setVisible(true); }
From source file:ModifyModelSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Modifying Model"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Fill model final DefaultListModel model = new DefaultListModel(); for (int i = 0, n = labels.length; i < n; i++) { model.addElement(labels[i]);/*ww w. ja v a 2 s .c om*/ } JList jlist = new JList(model); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1, BorderLayout.CENTER); frame.setSize(640, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); JComponent topComponent = new JButton("A"); splitPane.setTopComponent(topComponent); JComponent bottomComponent = new JButton("B"); splitPane.setBottomComponent(bottomComponent); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150);// w ww . java 2s .c om 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(); textField.setHorizontalAlignment(JTextField.CENTER); label.setLabelFor(textField);//from ww w .java 2 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.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setBorder(new EmptyBorder(2, 3, 2, 3)); JPanel textPanel = new JPanel(new BorderLayout(5, 5)); textPanel.add(new JScrollPane(new JTextArea("Top Text", 3, 20)), BorderLayout.PAGE_START); textPanel.add(new JScrollPane(new JTextArea("Main Text", 10, 10))); gui.add(textPanel, BorderLayout.CENTER); JPanel buttonCenter = new JPanel(new GridBagLayout()); buttonCenter.setBorder(new EmptyBorder(5, 5, 5, 5)); JPanel buttonPanel = new JPanel(new GridLayout(0, 1, 5, 5)); for (int ii = 1; ii < 6; ii++) { buttonPanel.add(new JButton("Button " + ii)); }// ww w.j a va 2 s . c om buttonCenter.add(buttonPanel); gui.add(buttonCenter, BorderLayout.LINE_END); JFrame f = new JFrame("Demo"); 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 f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); p.setOpaque(true);//from w w w .j av a 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:LoadingHTMLDocuments.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Tab Attributes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane editorPane = new JEditorPane(); editorPane.setEditorKit(new HTMLEditorKit()); String filename = "yourFile.htm"; FileReader reader = new FileReader(filename); editorPane.read(reader, filename);/* www. j a va 2 s .c o m*/ JScrollPane scrollPane = new JScrollPane(editorPane); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); Integer[][] board = { { 1, 1, 1, 1, 2, 0, 0, 0, 0 }, { 0, 0, 5, 0, 1, 0, 0, 2, 4 }, { 1, 0, 0, 4, 0, 0, 0, 3, 8 }, { 0, 0, 0, 6, 1, 0, 0, 3, 7 }, { 0, 0, 4, 5, 3, 8, 9, 4, 0 }, { 8, 0, 0, 0, 1, 7, 0, 4, 0 }, { 7, 4, 0, 0, 1, 6, 0, 3, 1 }, { 6, 1, 0, 0, 1, 0, 3, 3, 0 }, { 0, 0, 0, 0, 1, 1, 1, 1, 0 } }; String col[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; JTable table = new JTable(board, col); panel.add(table, BorderLayout.CENTER); frame.add(panel);/*from w w w. j ava 2 s .co m*/ frame.setSize(800, 500); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { final String START_STRING = "Start\n"; final int START_STRING_LENGTH = START_STRING.length(); JFrame frame = new JFrame("Navigation Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea textArea = new JTextArea(START_STRING); textArea.setCaretPosition(START_STRING_LENGTH); JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); NavigationFilter filter = new NavigationFilter() { public void setDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) { if (dot < START_STRING_LENGTH) { fb.setDot(START_STRING_LENGTH, bias); } else { fb.setDot(dot, bias);// w w w . ja v a2 s. com } } public void moveDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) { if (dot < START_STRING_LENGTH) { fb.setDot(START_STRING_LENGTH, bias); } else { fb.setDot(dot, bias); } } }; textArea.setNavigationFilter(filter); frame.setSize(250, 150); frame.setVisible(true); }
From source file:ListenerSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Offset Example"); Container content = frame.getContentPane(); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); final Document document = textArea.getDocument(); document.addDocumentListener(new MyListener()); content.add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 150);/* www .j ava2 s. c o m*/ frame.setVisible(true); }