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[]) { JFrame frame = new JFrame("Color Matted Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border solidBorder = new MatteBorder(10, 5, 2, 20, Color.RED); JButton solidButton = new JButton("10x5x2x20"); solidButton.setBorder(solidBorder);//from w w w .ja va 2 s. c om Container contentPane = frame.getContentPane(); contentPane.add(solidButton, BorderLayout.CENTER); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel bottomPanel = new JPanel(); bottomPanel.add(new JButton("Bottom Button")); bottomPanel.setBorder(BorderFactory.createTitledBorder("Bottom Panel")); JPanel centerPanel = new JPanel(); centerPanel.setBorder(BorderFactory.createTitledBorder("Center Panel")); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(bottomPanel, BorderLayout.PAGE_END); int eb = 25;/*from w ww. ja v a 2s. co m*/ mainPanel.setBorder(BorderFactory.createEmptyBorder(eb, eb, eb, eb)); mainPanel.setPreferredSize(new Dimension(500, 400)); JFrame frame = new JFrame("Main"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent topButton = new JButton("Left"); JComponent bottomButton = new JButton("Right"); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(topButton); splitPane.setBottomComponent(bottomButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);//from w ww. j a v a 2 s .com horizontalFrame.setVisible(true); splitPane.setDividerLocation(0.5); }
From source file:FormattedSample.java
public static void main(final String args[]) { JFrame frame = new JFrame("Formatted Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel datePanel = new JPanel(new BorderLayout()); DateFormat format = new SimpleDateFormat("yyyy--MMMM--dd"); JFormattedTextField dateTextField = new JFormattedTextField(format); datePanel.add(dateTextField, BorderLayout.CENTER); frame.add(datePanel, BorderLayout.NORTH); frame.add(new JTextField(), BorderLayout.SOUTH); frame.setSize(250, 100);/*from www . j av a 2 s. co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); final DrawPad drawPad = new DrawPad(); frame.add(drawPad, BorderLayout.CENTER); JButton clearButton = new JButton("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { drawPad.clear();/* w w w. j a v a2 s. c o m*/ } }); frame.add(clearButton, BorderLayout.SOUTH); frame.setSize(280, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:JScrollPaneHeadersandCorners.java
public static void main(String args[]) { final Object rows[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" }, { "four", "4" }, };/*from w w w .j ava 2 s .c o m*/ final Object headers[] = { "English", "#" }; JFrame frame = new JFrame("Table Printing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTable table = new JTable(rows, headers); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new JButton("...")); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JEditorPane Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); JEditorPane editor = new JEditorPane("text/html", "<H3>Help</H3><center><IMG src=file:///c:/a.jpg></center><li>One<li><i>Two</i><li><u>Three</u>"); editor.setEditable(false);// w w w .ja va 2 s .c o m JScrollPane scrollPane = new JScrollPane(editor); content.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:JListSelectionModeAnchor.java
public static void main(String args[]) { JFrame frame = new JFrame("Modifying Model"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(new String[] { "A", "B", "C" }); jlist.getSelectionModel().setAnchorSelectionIndex(0); jlist.getSelectionModel().setLeadSelectionIndex(2); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1, BorderLayout.CENTER); frame.setSize(640, 300);// ww w. j a va 2 s.c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultListModel model = new DefaultListModel(); model.ensureCapacity(100);/*from w w w .j a v a 2s. c o m*/ for (int i = 0; i < 100; i++) { model.addElement(Integer.toString(i)); } JList jlist2 = new JList(model); JScrollPane scrollPane2 = new JScrollPane(jlist2); frame.add(scrollPane2, BorderLayout.CENTER); frame.setSize(300, 350); frame.setVisible(true); jlist2.ensureIndexIsVisible(50); }
From source file:Main.java
public static void main(String args[]) { final Object rowData[][] = { { "1", "one", "I" }, { "2", "two", "II" }, { "3", "three", "III" } }; final String columnNames[] = { "#", "English", "Roman" }; final JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); JFrame frame = new JFrame("Resizing Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane, BorderLayout.CENTER); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); frame.setSize(300, 150);//from w ww.jav a 2 s .c o m frame.setVisible(true); }