List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:UpcaseFilter.java
public static void main(String[] args) { DocumentFilter dfilter = new UpcaseFilter(); JTextArea jta = new JTextArea(); JTextField jtf = new JTextField(); ((AbstractDocument) jta.getDocument()).setDocumentFilter(dfilter); ((AbstractDocument) jtf.getDocument()).setDocumentFilter(dfilter); JFrame frame = new JFrame("UpcaseFilter"); frame.getContentPane().add(jta, "Center"); frame.getContentPane().add(jtf, "South"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 120);/*w w w. j av a2 s. c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { SpinnerNumberModel model = new SpinnerNumberModel(0.0, -1000.0, 1000.0, 0.1); JSpinner s = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(s); s.setEditor(editor);/*from w ww .j av a 2 s.com*/ JTextField stepText = new JTextField(10); JButton bStepSet = new JButton("Set Step"); bStepSet.addActionListener(e -> { Double val = Double.parseDouble(stepText.getText().trim()); model.setStepSize(val); }); JFrame f = new JFrame(); Container c = f.getContentPane(); c.add(s); JPanel southPanel = new JPanel(); southPanel.add(stepText); southPanel.add(bStepSet); c.add(southPanel, BorderLayout.SOUTH); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:ColorPan.java
public static void main(String[] args) { JFrame f = new JFrame("ColorPan"); f.getContentPane().add(new ColorPan()); f.setSize(300, 300);/*w ww . j a v a 2 s.co m*/ f.setLocation(100, 100); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { JFrame jf = new JFrame("Demo"); Container cp = jf.getContentPane(); MyCanvas tl = new MyCanvas(); cp.add(tl);//www. j a v a 2s. c om jf.setSize(300, 200); jf.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new MainClass()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200);// w ww . j a v a 2s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); ButtonGroup group = new ButtonGroup(); JRadioButton option = new JRadioButton("French Fries", true); group.add(option);//from w w w . j av a 2 s .c o m contentPane.add(option); option = new JRadioButton("Onion Rings", false); group.add(option); contentPane.add(option); option = new JRadioButton("Ice Cream", false); group.add(option); contentPane.add(option); frame.setSize(200, 200); frame.show(); }
From source file:SpinnerDemo.java
public static void main(String[] args) { JFrame jf = new JFrame("It Spins"); Container cp = jf.getContentPane(); cp.setLayout(new GridLayout(0, 1)); // Create a JSpinner using one of the pre-defined SpinnerModels JSpinner dates = new JSpinner(new SpinnerDateModel()); cp.add(dates);// w w w. j av a 2 s . c o m // Create a JSPinner using a SpinnerListModel. String[] data = { "One", "Two", "Three" }; JSpinner js = new JSpinner(new SpinnerListModel(data)); cp.add(js); jf.setSize(100, 80); jf.setVisible(true); }
From source file:ToolBarTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JToolBar bar;// ww w . j a va2s.c om bar = new JToolBar(); JToggleButton jb; for (int i = 0; i < 8; i++) { jb = new JToggleButton("" + i); bar.add(jb); if (i == 5) { bar.addSeparator(); } } contentPane.add(bar, BorderLayout.NORTH); frame.setSize(300, 300); frame.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); MyTableModel model = new MyTableModel(); JTable table = new JTable(model); table.setRowHeight(80);/*from ww w .j a v a2 s. com*/ table.getColumnModel().getColumn(0).setCellRenderer(new ImageRenderer()); JScrollPane pane = new JScrollPane(table); frame.getContentPane().add(BorderLayout.CENTER, pane); frame.setSize(500, 400); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Add the toolbar to a frame JFrame frame = new JFrame(); JToolBar toolbar = new JToolBar(); frame.getContentPane().add(toolbar, BorderLayout.NORTH); frame.pack();//w w w . j a va2 s. c om frame.setVisible(true); }