List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:ButtonBorderTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Fourth Button"); Container contentPane = frame.getContentPane(); Icon icon = new ImageIcon("java2s.gif"); JButton b = new JButton("Button!"); Border bored = BorderFactory.createMatteBorder(10, 5, 10, 5, icon); b.setBorder(bored);/*from w w w . ja v a 2 s .c om*/ contentPane.add(b, BorderLayout.CENTER); frame.setSize(350, 200); frame.show(); }
From source file:TextFieldExample.java
public static void main(String[] args) { try {//from w ww . j a v a 2s . c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Text Field Examples"); f.getContentPane().setLayout(new FlowLayout()); f.getContentPane().add(new JTextField("Text field 1")); f.getContentPane().add(new JTextField("Text field 2", 8)); JTextField t = new JTextField("Text field 3", 8); t.setHorizontalAlignment(JTextField.RIGHT); f.getContentPane().add(t); t = new JTextField("Text field 4", 8); t.setHorizontalAlignment(JTextField.CENTER); f.getContentPane().add(t); f.getContentPane().add(new JTextField("Text field 5", 3)); f.pack(); f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JTextField field = new JTextField(30); ((AbstractDocument) (field.getDocument())).setDocumentFilter(new DocumentFilter() { public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { System.out.println("insert"); fb.insertString(offset, string.toUpperCase(), attr); }/*from w w w .j a v a 2 s .c o m*/ public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr) throws BadLocationException { System.out.println("replace"); fb.replace(offset, length, string.toUpperCase(), attr); } }); JFrame frame = new JFrame("User Information"); frame.getContentPane().add(field); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:DragImage.java
public static void main(String[] args) { String imageFile = "A.jpg"; // Turn off double buffering RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(DragImage.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_DEFAULT); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new DragImage(image)); frame.setSize(300, 300);/* ww w. j a v a2s . co m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new MyPanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();//from w ww . ja va2s . c om frame.setVisible(true); }
From source file:TabbedPaneTest.java
public static void main(String args[]) { JFrame frame = new JFrame("JTabbedPane"); final Container contentPane = frame.getContentPane(); JTabbedPane jtp = new JTabbedPane(); contentPane.add(jtp, BorderLayout.CENTER); for (int i = 0; i < 5; i++) { JButton button = new JButton("Card " + i); jtp.add("Btn " + i, button); }/*from www . j ava2 s . co m*/ frame.setSize(300, 200); frame.show(); }
From source file:InternalTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JLayeredPane desktop = new JDesktopPane(); desktop.setOpaque(false);/* ww w . j av a2 s.c o m*/ desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER); desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER); desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER); contentPane.add(desktop, BorderLayout.CENTER); frame.setSize(300, 300); frame.show(); }
From source file:JNLPTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); JLabel label = new JLabel("Hello, JNLP"); content.add(label, BorderLayout.CENTER); frame.setSize(200, 200);//from w w w.ja v a2 s .c om frame.show(); try { Thread.sleep(5000); } catch (InterruptedException ignored) { } finally { System.exit(0); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); Container container = frame.getContentPane(); GridBagLayout gbl = new GridBagLayout(); container.setLayout(gbl);// ww w. java 2s .co m // Place a component at cell location (1,1) GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; JButton component = new JButton("a"); // Associate the gridbag constraints with the component gbl.setConstraints(component, gbc); container.add(component); frame.pack(); frame.setVisible(true); }
From source file:HeaderlessSample.java
public static void main(String args[]) { Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "Column 1", "Column 2", "Column 3" }; // JTable table = new HeaderlessTable(rowData, columnNames); JTable table = new JTable(rowData, columnNames); table.setTableHeader(null);//from w w w . ja v a 2 s . com JScrollPane scrollPane = new JScrollPane(table); // scrollPane.setColumnHeaderView(null); JFrame frame = new JFrame("Headerless Table"); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }