List of usage examples for java.awt Container add
public Component add(Component comp)
From source file:WSRTreeVisualizer.java
/** * a driver for this demo/*from ww w. j ava2 s . c om*/ */ public static void main(String[] args) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); content.add(new WSRTreeVisualizer()); frame.pack(); frame.setVisible(true); }
From source file:EdgeLabelDemo.java
/** * a driver for this demo//from www . jav a 2 s . com */ public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); content.add(new EdgeLabelDemo()); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("SpringLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); // Set the content pane's layout as SpringLayout SpringLayout springLayout = new SpringLayout(); contentPane.setLayout(springLayout); // Add two JButtons to the content pane JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Little Bigger Button 2"); contentPane.add(b1); contentPane.add(b2);/*from w ww . j ava 2 s. c o m*/ frame.pack(); frame.setVisible(true); }
From source file:L2RTreeLayoutDemo.java
/** * a driver for this demo// w ww. j av a2 s . c om */ public static void main(String[] args) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); content.add(new L2RTreeLayoutDemo()); frame.pack(); frame.setVisible(true); }
From source file:SpringDemo4.java
public static void main(String[] args) { JFrame frame = new JFrame("SpringDemo4"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set up the content pane. Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout);/*w ww .j a va 2s . c o m*/ // Create and add the components. JLabel label = new JLabel("Label: "); JTextField textField = new JTextField("Text field", 15); contentPane.add(label); contentPane.add(textField); // Adjust constraints for the label so it's at (5,5). SpringLayout.Constraints labelCons = layout.getConstraints(label); labelCons.setX(Spring.constant(5)); labelCons.setY(Spring.constant(5)); // Adjust constraints for the text field so it's at // (<label's right edge> + 5, 5). SpringLayout.Constraints textFieldCons = layout.getConstraints(textField); textFieldCons.setX(Spring.sum(Spring.constant(5), labelCons.getConstraint(SpringLayout.EAST))); textFieldCons.setY(Spring.constant(5)); // Adjust constraints for the content pane. setContainerSize(contentPane, 5); // Display the window. frame.pack(); frame.setVisible(true); }
From source file:by.bsuir.main.Graph.java
/** * a driver for this demo/* w ww. ja v a 2 s. c o m*/ */ public static void main(String[] args) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); content.add(new Graph()); frame.pack(); frame.setVisible(true); }
From source file:URLMonitorPanel.java
public static void main(String[] args) throws Exception { JFrame frame = new JFrame("URL Monitor"); Container c = frame.getContentPane(); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); Timer t = new Timer(); String[] u = new String[] { "http://www.java2s.com", "http://www.java2s.com" }; for (int i = 0; i < u.length; i++) { c.add(new URLMonitorPanel(u[i], t)); }/* www. ja va2 s.co m*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); frame.pack(); frame.show(); }
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 ava 2 s .c om GridBagConstraints gbc = new GridBagConstraints(); JButton component1 = new JButton("a"); JButton component2 = new JButton("b"); gbc.gridx = 1; gbc.gridy = 1; gbl.setConstraints(component1, gbc); container.add(component1); gbc.gridx = 0; gbc.gridy = 0; gbl.setConstraints(component2, gbc); container.add(component2); container.add(component1); container.add(component2); frame.pack(); frame.setVisible(true); }
From source file:com.google.code.facebook.graph.sna.applet.BalloonLayoutDemo.java
/** * a driver for this demo//from w w w . ja v a 2 s .co m */ public static void main(String[] args) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); content.add(new BalloonLayoutDemo()); frame.pack(); frame.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 . java 2s .c o m GridBagConstraints gbc = new GridBagConstraints(); JButton component1 = new JButton("a"); JButton component2 = new JButton("b"); gbc.gridx = 1; gbc.gridy = 1; gbl.setConstraints(component1, gbc); container.add(component1); gbc.gridx = 0; gbc.gridy = 0; gbl.setConstraints(component2, gbc); container.add(component2); container.add(component1); container.add(component2); frame.pack(); frame.setVisible(true); gbl.layoutContainer(container); int[][] dim = gbl.getLayoutDimensions(); int cols = dim[0].length; int rows = dim[1].length; System.out.println(cols); System.out.println(rows); }