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(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); Container c = frame.getContentPane(); panel.setSize(100, 100);/*from w w w.jav a 2 s .c o m*/ panel.setLayout(new GridLayout(1000, 1)); for (int i = 0; i < 1000; i++) panel.add(new JLabel("JLabel " + i)); JScrollPane jsp = new JScrollPane(panel); c.add(jsp); frame.setSize(100, 100); frame.setVisible(true); }
From source file:edu.uci.ics.jung.samples.SimpleGraphDraw.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void main(String[] args) throws IOException { JFrame jf = new JFrame(); Graph g = getGraph();//from www .j a va 2 s . c o m VisualizationViewer vv = new VisualizationViewer(new FRLayout(g)); jf.getContentPane().add(vv); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GroupLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); GroupLayout groupLayout = new GroupLayout(contentPane); groupLayout.setAutoCreateGaps(true); groupLayout.setAutoCreateContainerGaps(true); contentPane.setLayout(groupLayout);/*w ww. j a v a 2s . com*/ JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button Second"); JButton b3 = new JButton("3"); JButton b4 = new JButton("4"); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(LEADING).addComponent(b1).addComponent(b3)) .addGroup(groupLayout.createParallelGroup(TRAILING).addComponent(b2).addComponent(b4))); groupLayout.setVerticalGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(BASELINE).addComponent(b1).addComponent(b2)) .addGroup(groupLayout.createParallelGroup(BASELINE).addComponent(b3).addComponent(b4))); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { MainPanelGen mainPanelGen = new MainPanelGen(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanelGen.getMainPanel()); frame.pack();//from w ww . jav a2 s. c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("SpringLayout2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); SpringLayout springLayout = new SpringLayout(); contentPane.setLayout(springLayout); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button Second"); contentPane.add(b1);// www . j ava 2s. c o m contentPane.add(b2); springLayout.putConstraint(SpringLayout.WEST, b1, 10, SpringLayout.WEST, contentPane); springLayout.putConstraint(SpringLayout.NORTH, b1, 20, SpringLayout.NORTH, contentPane); springLayout.putConstraint(SpringLayout.WEST, b2, 10, SpringLayout.EAST, b1); springLayout.putConstraint(SpringLayout.NORTH, b2, 20, SpringLayout.NORTH, contentPane); springLayout.putConstraint(SpringLayout.SOUTH, contentPane, 10, SpringLayout.SOUTH, b1); springLayout.putConstraint(SpringLayout.EAST, contentPane, 10, SpringLayout.EAST, b2); frame.pack(); frame.setVisible(true); }
From source file:KeymapExample.java
public static void main(String[] args) { JTextArea area = new JTextArea(6, 32); Keymap parent = area.getKeymap(); Keymap newmap = JTextComponent.addKeymap("KeymapExampleMap", parent); KeyStroke u = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK); Action actionU = new UpWord(); newmap.addActionForKeyStroke(u, actionU); Action actionList[] = area.getActions(); Hashtable lookup = new Hashtable(); for (int j = 0; j < actionList.length; j += 1) lookup.put(actionList[j].getValue(Action.NAME), actionList[j]); KeyStroke L = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK); Action actionL = (Action) lookup.get(DefaultEditorKit.selectLineAction); newmap.addActionForKeyStroke(L, actionL); KeyStroke W = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK); Action actionW = (Action) lookup.get(DefaultEditorKit.selectWordAction); newmap.addActionForKeyStroke(W, actionW); area.setKeymap(newmap);/* w w w . j a v a2s.c o m*/ JFrame f = new JFrame("KeymapExample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(area), BorderLayout.CENTER); area.setText("www.\n java2s \n .com."); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); JPanel centeredPanel = new JPanel(); centeredPanel.add(new JButton("one")); centeredPanel.add(new JButton("two")); f.getContentPane().add(centeredPanel); f.pack();/*from w ww .ja v a2 s . c o m*/ f.setVisible(true); }
From source file:JButtonKnowsBgColor.java
public static void main(String[] args) { JButtonKnowsBgColor jbkbc = new JButtonKnowsBgColor("choose back", Color.RED, true); JButtonKnowsBgColor jbkbc1 = new JButtonKnowsBgColor("choose fore", Color.BLUE, false); JFrame jf = new JFrame(); jf.setLayout(new BorderLayout()); jf.getContentPane().add(jbkbc, BorderLayout.NORTH); jf.getContentPane().add(jbkbc1, BorderLayout.CENTER); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setSize(100, 200);// www .ja v a 2 s.c o m jf.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(""); JLabel label = new JLabel("Move this window's title bar to demonstrate screen edge snapping."); frame.getContentPane().add(label); frame.pack();// w w w. ja va2s . c om frame.addComponentListener(new Main()); frame.setVisible(true); }
From source file:WindowSnapper.java
public static void main(String[] args) { JFrame frame = new JFrame(""); JLabel label = new JLabel("Move this window's title bar to demonstrate screen edge snapping."); frame.getContentPane().add(label); frame.pack();/*from w ww.j a v a 2 s . c o m*/ frame.addComponentListener(new WindowSnapper()); frame.setVisible(true); }