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(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrames[] = { new JInternalFrame("Can Do All", true, true, true, true), new JInternalFrame("Not Resizable", false, true, true, true), new JInternalFrame("Not Closable", true, false, true, true), new JInternalFrame("Not Maximizable", true, true, false, true), new JInternalFrame("Not Iconifiable", true, true, true, false) }; int pos = 0;/*from w w w . jav a 2 s .co m*/ for (JInternalFrame internalFrame : internalFrames) { desktop.add(internalFrame); internalFrame.setBounds(pos * 25, pos * 25, 200, 100); pos++; JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); } desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); JInternalFrame[] frames = desktop.getAllFrames(); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrames[] = { new JInternalFrame("Can Do All", true, true, true, true), new JInternalFrame("Not Resizable", false, true, true, true), new JInternalFrame("Not Closable", true, false, true, true), new JInternalFrame("Not Maximizable", true, true, false, true), new JInternalFrame("Not Iconifiable", true, true, true, false) }; int pos = 0;/* www.j a v a 2s.co m*/ for (JInternalFrame internalFrame : internalFrames) { desktop.add(internalFrame); internalFrame.setBounds(pos * 25, pos * 25, 200, 100); pos++; JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); } desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); desktop.selectFrame(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrames[] = { new JInternalFrame("Can Do All", true, true, true, true), new JInternalFrame("Not Resizable", false, true, true, true), new JInternalFrame("Not Closable", true, false, true, true), new JInternalFrame("Not Maximizable", true, true, false, true), new JInternalFrame("Not Iconifiable", true, true, true, false) }; int pos = 0;/*w w w. ja v a 2 s . co m*/ for (JInternalFrame internalFrame : internalFrames) { desktop.add(internalFrame); internalFrame.setBounds(pos * 25, pos * 25, 200, 100); pos++; JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); } desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); JInternalFrame[] frames = desktop.getAllFramesInLayer(0); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);//from w w w.j av a2 s.c o m Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); frame.add(new JScrollPane(tree), BorderLayout.CENTER); tree.expandRow(1); tree.scrollRowToVisible(2); tree.revalidate(); frame.setSize(300, 300); frame.setVisible(true); }
From source file:UsingTableModelToContruct.java
public static void main(String args[]) { TableModel model = new AbstractTableModel() { Object rowData[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" } }; Object columnNames[] = { "English", "#" }; public String getColumnName(int column) { return columnNames[column].toString(); }//from w ww. j av a 2s.c o m public int getRowCount() { return rowData.length; } public int getColumnCount() { return columnNames.length; } public Object getValueAt(int row, int col) { return rowData[row][col]; } }; JTable table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); JFrame frame = new JFrame("Resizing Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:KeyTextTester.java
public static void main(String args[]) { JFrame frame = new JFrame("Key Text Sample"); KeyTextComponent keyTextComponent = new KeyTextComponent(); final JTextField textField = new JTextField(); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String keyText = actionEvent.getActionCommand(); textField.setText(keyText);/*from w w w . j a v a2s. c om*/ } }; keyTextComponent.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(keyTextComponent, BorderLayout.CENTER); contentPane.add(textField, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:AllAvailableFontsComboBox.java
public static void main(String s[]) { JFrame f = new JFrame("FontSelection"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w. j a va 2s. c om } }); AllAvailableFontsComboBox fontSelection = new AllAvailableFontsComboBox(); f.getContentPane().add(fontSelection, BorderLayout.CENTER); f.setSize(new Dimension(350, 250)); f.setVisible(true); }
From source file:ShowOff.java
public static void main(String[] args) { try {/* ww w. j a v a2 s . co m*/ String filename = "largeJava2sLogo.jpg"; String message = "Java Source and Support"; int split = 4; JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); ShowOff showOff = new ShowOff(filename, message, split); f.add(showOff, BorderLayout.CENTER); f.setSize(f.getPreferredSize()); f.setResizable(false); f.setVisible(true); } catch (Exception e) { System.out.println(e); System.exit(0); } }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> rowOne = new Vector<String>(); rowOne.addElement("Row1-Column1"); rowOne.addElement("Row1-Column2"); rowOne.addElement("Row1-Column3"); Vector<String> rowTwo = new Vector<String>(); rowTwo.addElement("Row2-Column1"); rowTwo.addElement("Row2-Column2"); rowTwo.addElement("Row2-Column3"); Vector<Vector> rowData = new Vector<Vector>(); rowData.addElement(rowOne);//from ww w. j a v a2 s . c om rowData.addElement(rowTwo); Vector<String> columnNames = new Vector<String>(); columnNames.addElement("Column One"); columnNames.addElement("Column Two"); columnNames.addElement("Column Three"); JTable table = new JTable(rowData, columnNames); table.setValueAt("aa", 0, 0); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:LabelHeaderSample.java
public static void main(String args[]) { final Object rows[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" } }; JFrame frame = new JFrame("Label Header"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String headers[] = { "English", "#" }; JTable table = new JTable(rows, headers); JScrollPane scrollPane = new JScrollPane(table); JLabel headerRenderer = new DefaultTableCellRenderer(); String columnName = table.getModel().getColumnName(0); headerRenderer.setText(columnName);// w w w . j a v a 2 s.com headerRenderer.setToolTipText("text"); TableColumnModel columnModel = table.getColumnModel(); TableColumn englishColumn = columnModel.getColumn(0); englishColumn.setHeaderRenderer((TableCellRenderer) headerRenderer); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }