List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:TextLayoutRight.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setSize(300, 300);/* www . j ava 2 s . co m*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new TextLayoutRight()); f.setVisible(true); }
From source file:TextLayoutCenter.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setSize(300, 300);//from w ww. j a v a2 s. c o m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new TextLayoutCenter()); f.setVisible(true); }
From source file:TimeViewer.java
public static void main(String[] args) { JFrame f = new JFrame("Time Viewer"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new TimeViewer()); f.pack();// w ww . j av a 2 s.co m f.setVisible(true); }
From source file:EditComboBox.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; JFrame frame = new JFrame("Editable JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JComboBox comboBox = new JComboBox(labels); comboBox.setMaximumRowCount(5);//from ww w .ja va 2 s. com comboBox.setEditable(true); contentPane.add(comboBox, BorderLayout.NORTH); final JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); contentPane.add(scrollPane, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { textArea.append("Selected: " + comboBox.getSelectedItem()); textArea.append(", Position: " + comboBox.getSelectedIndex()); textArea.append(System.getProperty("line.separator")); } }; comboBox.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200, 200);//from www. jav a2 s. c o m f.getContentPane().setLayout(new BorderLayout()); JTextPane jtp = new JTextPane(); jtp.setEditorKit(new WrapEditorKit()); JScrollPane jsp = new JScrollPane(jtp); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); f.getContentPane().add(jsp, BorderLayout.CENTER); jtp.setText("thisIsATestThisisAtestthisIsATestThisisAtestthisIsATestThisisAtest"); f.setVisible(true); }
From source file:FactoryDemo.java
public static void main(String argv[]) { JFrame f = new JFrame("FactoryDemo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(demo1(), BorderLayout.NORTH); f.getContentPane().add(demo2(), BorderLayout.SOUTH); f.setSize(240, 160);/*ww w . j a va 2s. c o m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel panel = new JPanel(new GridLayout(0, 1)); Border border = BorderFactory.createTitledBorder("Examples"); panel.setBorder(border);//from www .j a v a2 s . co m ButtonGroup group = new ButtonGroup(); AbstractButton abstract1 = new JToggleButton("Toggle Button"); panel.add(abstract1); group.add(abstract1); AbstractButton abstract2 = new JRadioButton("Radio Button"); panel.add(abstract2); group.add(abstract2); AbstractButton abstract3 = new JCheckBox("Check Box"); panel.add(abstract3); group.add(abstract3); AbstractButton abstract4 = new JRadioButtonMenuItem("Radio Button Menu Item"); panel.add(abstract4); group.add(abstract4); AbstractButton abstract5 = new JCheckBoxMenuItem("Check Box Menu Item"); panel.add(abstract5); group.add(abstract5); JFrame frame = new JFrame("Button Group"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:TextForm.java
public static void main(String[] args) { String[] labels = { "First Name", "Middle Initial", "Last Name", "Age" }; char[] mnemonics = { 'F', 'M', 'L', 'A' }; int[] widths = { 15, 1, 15, 3 }; String[] descs = { "First Name", "Middle Initial", "Last Name", "Age" }; final TextForm form = new TextForm(labels, mnemonics, widths, descs); JButton submit = new JButton("Submit Form"); submit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(form.getText(0) + " " + form.getText(1) + ". " + form.getText(2) + ", age " + form.getText(3));/* ww w . j a v a2s . c om*/ } }); JFrame f = new JFrame("Text Form Example"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(form, BorderLayout.NORTH); JPanel p = new JPanel(); p.add(submit); f.getContentPane().add(p, BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JButton button = new JButton("Start Animation"); button.addActionListener(new Main(frame)); frame.getContentPane().add(button); frame.setSize(300, 300);//from ww w . j a v a 2 s . co m frame.setVisible(true); }
From source file:TextFormat.java
public static void main(String[] args) { JFrame jf = new JFrame("Demo"); Container cp = jf.getContentPane(); TextFormat tl = new TextFormat(); tl.setFont(new Font("SansSerif", Font.BOLD, 42)); tl.setText("The quick brown fox jumped over the lazy cow"); cp.add(tl);// ww w .ja v a2 s. co m jf.setSize(300, 200); jf.setVisible(true); }