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[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); Button btn = new Button("OK"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); gs.setFullScreenWindow(null); }// w w w. j a v a 2 s . co m }); Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); win.add(btn, BorderLayout.CENTER); try { gs.setFullScreenWindow(win); win.validate(); } finally { gs.setFullScreenWindow(null); } }
From source file:JTextAreaBackgroundSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Background Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ImageIcon imageIcon = new ImageIcon("yourFile.gif"); JTextArea textArea = new JTextArea() { Image image = imageIcon.getImage(); Image grayImage = GrayFilter.createDisabledImage(image); {//from w w w .j a v a2 s.c o m setOpaque(false); } public void paint(Graphics g) { g.drawImage(grayImage, 0, 0, this); super.paint(g); } }; JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 250); frame.setVisible(true); }
From source file:SparseTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Sparse Test"); String headers[] = { "English", "Japanese" }; TableModel model = new SparseTableModel(10, headers); JTable table = new JTable(model); model.setValueAt("one", 0, 0); model.setValueAt("ten", 9, 0); model.setValueAt("roku - \u516D", 5, 1); model.setValueAt("hachi - \u516B", 8, 1); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150);//from w w w. java 2 s . c o m frame.setVisible(true); }
From source file:Main.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(label); JButton jButton1 = new JButton(); jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane.setViewportBorder(new LineBorder(Color.RED)); jScrollPane.getViewport().add(jButton1, null); frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150);//from w ww . j av a 2s.c om frame.setVisible(true); }
From source file:ToolBarSample.java
public static void main(final String args[]) { JFrame frame = new JFrame("JToolBar Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true);/* ww w .ja v a 2 s .c o m*/ JButton button = new JButton("button"); toolbar.add(button); toolbar.addSeparator(); toolbar.add(new JButton("button 2")); toolbar.add(new JComboBox(new String[] { "A", "B", "C" })); Container contentPane = frame.getContentPane(); contentPane.add(toolbar, BorderLayout.NORTH); JTextArea textArea = new JTextArea(); JScrollPane pane = new JScrollPane(textArea); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(350, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Pick to Change Background"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Color initialBackground = button.getBackground(); Color background = JColorChooser.showDialog(null, "JColorChooser Sample", initialBackground); if (background != null) { button.setBackground(background); }/*from w w w. j av a 2 s. c o m*/ } }; button.addActionListener(actionListener); f.add(button, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:FileSamplePanel.java
public static void main(String args[]) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel directoryLabel = new JLabel(" "); directoryLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); frame.add(directoryLabel, BorderLayout.NORTH); final JLabel filenameLabel = new JLabel(" "); filenameLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); frame.add(filenameLabel, BorderLayout.SOUTH); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setControlButtonsAreShown(false); frame.add(fileChooser, BorderLayout.CENTER); // Create ActionListener ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource(); String command = actionEvent.getActionCommand(); if (command.equals(JFileChooser.APPROVE_SELECTION)) { File selectedFile = theFileChooser.getSelectedFile(); directoryLabel.setText(selectedFile.getParent()); filenameLabel.setText(selectedFile.getName()); } else if (command.equals(JFileChooser.CANCEL_SELECTION)) { directoryLabel.setText(" "); filenameLabel.setText(" "); }//from w w w. ja v a 2 s . c om } }; fileChooser.addActionListener(actionListener); frame.pack(); frame.setVisible(true); }
From source file:DynamicUtilTreeNodeDemo.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); Hashtable<String, Object> hashtable = new Hashtable<String, Object>(); hashtable.put("Two", new String[] { "A", "B", "C" }); Hashtable<Object, Object> innerHashtable = new Hashtable<Object, Object>(); innerHashtable.put("Two", new String[] { "A", "B", "C" }); hashtable.put("Three", innerHashtable); JTree.DynamicUtilTreeNode.createChildren(root, hashtable); JTree tree = new JTree(root); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150);//w w w . j a v a2 s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Main testJFrame = new Main(); List<String> columns = new ArrayList<String>(); List<String[]> values = new ArrayList<String[]>(); columns.add("col1"); columns.add("col2"); columns.add("col3"); for (int i = 0; i < 100; i++) { values.add(new String[] { "val" + i + " col1", "val" + i + " col2", "val" + i + " col3" }); }//w w w .ja v a 2 s.c o m TableModel tableModel = new DefaultTableModel(values.toArray(new Object[][] {}), columns.toArray()); JTable table = new JTable(tableModel); testJFrame.setLayout(new BorderLayout()); testJFrame.add(new JScrollPane(table), BorderLayout.CENTER); testJFrame.add(table.getTableHeader(), BorderLayout.NORTH); testJFrame.setVisible(true); testJFrame.setSize(200, 200); }
From source file:Main.java
public static void main(String args[]) throws Exception { SplashScreen splash = SplashScreen.getSplashScreen(); Graphics2D g = (Graphics2D) splash.createGraphics(); System.out.println(splash.getBounds()); Dimension dim = splash.getSize(); for (int i = 0; i < 100; i++) { g.setColor(Color.RED);// www . j a v a2s.co m g.fillRect(50, 50, dim.width - 100, dim.height - 100); splash.update(); try { Thread.sleep(250); } catch (InterruptedException ignored) { } } JFrame frame = new JFrame("Splash Me2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Hello, Splash", JLabel.CENTER); frame.add(label, BorderLayout.CENTER); frame.setSize(300, 95); frame.setVisible(true); }