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) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }/*from ww w .j a va 2 s . com*/ }); System.out.println(jb.getActionCommand()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }//from ww w.j a v a 2s . c o m }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { File sourceimage = new File("source.gif"); Image image = ImageIO.read(sourceimage); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack();//w ww . j a v a 2 s.c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }// www. j av a 2s . com }); System.out.println(jb.getAction()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:AlignY.java
public static void main(String args[]) { JFrame frame = new JFrame("Y Alignment"); JPanel contentPane = (JPanel) frame.getContentPane(); BoxLayout layout = new BoxLayout(contentPane, BoxLayout.X_AXIS); contentPane.setLayout(layout);/*from w ww.j a v a2 s . co m*/ JButton button = new JButton("0.0"); button.setAlignmentY(Component.TOP_ALIGNMENT); contentPane.add(button); button = new JButton("1.0"); button.setAlignmentY(Component.BOTTOM_ALIGNMENT); contentPane.add(button); button = new JButton("0.5"); button.setAlignmentY(Component.CENTER_ALIGNMENT); contentPane.add(button); frame.setSize(200, 100); frame.show(); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Spinning"); Container contentPane = frame.getContentPane(); String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SpinnerModel model = new SpinnerListModel(months); JSpinner spinner = new JSpinner(model); contentPane.add(spinner, BorderLayout.NORTH); SpinnerDateModel model2 = new SpinnerDateModel(); model2.setCalendarField(Calendar.WEEK_OF_MONTH); JSpinner spinner2 = new JSpinner(model2); JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy"); spinner2.setEditor(editor2);//w ww. j a v a 2s.c om frame.getContentPane().add(spinner2, BorderLayout.CENTER); SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5); JSpinner spinner3 = new JSpinner(model3); frame.getContentPane().add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 100); frame.setVisible(true); }
From source file:SpinnerTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Spinning"); Container contentPane = frame.getContentPane(); String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SpinnerModel model = new SpinnerListModel(months); JSpinner spinner = new JSpinner(model); contentPane.add(spinner, BorderLayout.NORTH); SpinnerDateModel model2 = new SpinnerDateModel(); model2.setCalendarField(Calendar.WEEK_OF_MONTH); JSpinner spinner2 = new JSpinner(model2); JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy"); spinner2.setEditor(editor2);/*from w w w.j a v a2 s . c om*/ frame.getContentPane().add(spinner2, BorderLayout.CENTER); SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5); JSpinner spinner3 = new JSpinner(model3); frame.getContentPane().add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 100); frame.show(); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JTextArea b = new JTextArea(); b.setPreferredSize(new Dimension(600, 600)); JScrollPane pane = new JScrollPane(b); AdjustmentListener hListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Horizontal: "); dumpInfo(e);//from w w w . j ava 2s .c o m } }; JScrollBar hBar = pane.getHorizontalScrollBar(); hBar.addAdjustmentListener(hListener); AdjustmentListener vListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Vertical: "); dumpInfo(e); } }; JScrollBar vBar = pane.getVerticalScrollBar(); vBar.addAdjustmentListener(vListener); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { String url = "http://www.yahoo.com"; JEditorPane editor = new JEditorPane(url); editor.setEditable(false);// w w w .jav a 2s . c om JScrollPane pane = new JScrollPane(editor); JFrame f = new JFrame("HTML Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(pane); f.setSize(800, 600); f.setVisible(true); }
From source file:Main.java
public static void main(String[] av) { JFrame frame = new JFrame(); Container cp = frame.getContentPane(); cp.add(new DriveTree(new File("."))); frame.pack();//from ww w . j av a 2 s .c o m frame.setVisible(true); frame.setSize(300, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }