List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Fourth Button"); Container contentPane = frame.getContentPane(); JButton b = new JButton("Button!"); Border bored = BorderFactory.createLineBorder(Color.RED); b.setBorder(bored);//from ww w. j a v a 2 s. c o m contentPane.add(b, BorderLayout.CENTER); frame.setSize(350, 200); frame.show(); }
From source file:Main.java
public static void main(String[] args) { String imageFile = "A.jpg"; RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_SMOOTH); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new Main(image)); frame.setSize(300, 300);// ww w . j a v a2s . c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String imageFile = "A.jpg"; RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_DEFAULT); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new Main(image)); frame.setSize(300, 300);/* www . j a v a 2 s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String imageFile = "A.jpg"; RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_FAST); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new Main(image)); frame.setSize(300, 300);//from w w w . j a v a2 s . c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:SmoothMove.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new SmoothMove()); f.setSize(200, 200);// w w w . j a v a2s .c o m f.show(); }
From source file:Main.java
public static void main(String[] args) { String imageFile = "A.jpg"; RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_AREA_AVERAGING); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new Main(image)); frame.setSize(300, 300);//from w w w . j a v a2 s . com frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:ColorBlocks.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new ColorBlocks()); f.setSize(350, 250);/*from w ww.j ava 2s. c om*/ f.show(); }
From source file:MyCanvas.java
public static void main(String[] a) { JFrame window = new JFrame(); window.setBounds(30, 30, 300, 300);/*from ww w . j a v a 2 s .c o m*/ window.getContentPane().add(new MyCanvas()); window.setVisible(true); }
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);// w w w . j a v a2 s . co m GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; JButton component = new JButton("a"); gbl.setConstraints(component, gbc); container.add(component); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { 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); }// w ww .ja v a2s .c om 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); }