List of usage examples for javax.swing JFrame setContentPane
@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.") public void setContentPane(Container contentPane)
contentPane
property. From source file:SpringCompactGrid.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.//from www . j a v a2s . c o m */ private static void createAndShowGUI() { JPanel panel = new JPanel(new SpringLayout()); int rows = 10; int cols = 10; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { int anInt = (int) Math.pow(r, c); JTextField textField = new JTextField(Integer.toString(anInt)); panel.add(textField); } } //Lay out the panel. SpringUtilities.makeCompactGrid(panel, //parent rows, cols, 3, 3, //initX, initY 3, 3); //xPad, yPad //Create and set up the window. JFrame frame = new JFrame("SpringCompactGrid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. panel.setOpaque(true); //content panes must be opaque frame.setContentPane(panel); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:components.PasswordDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event dispatch thread./* ww w . j a v a 2 s . c o m*/ */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("PasswordDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. final PasswordDemo newContentPane = new PasswordDemo(frame); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Make sure the focus goes to the right component //whenever the frame is initially given the focus. frame.addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { newContentPane.resetFocus(); } }); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:events.TreeExpandEventDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./*from w w w . j a va 2 s .com*/ */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("TreeExpandEventDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new TreeExpandEventDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:SpringGrid.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w w w. java2 s .c o m*/ private static void createAndShowGUI() { // Create the panel and populate it. JPanel panel = new JPanel(new SpringLayout()); for (int i = 0; i < 9; i++) { JTextField textField = new JTextField(Integer.toString(i)); // Make the 4th field extra big. if (i == 4) { textField.setText("This one is extra long."); } panel.add(textField); } // Lay out the panel. SpringUtilities.makeGrid(panel, 3, 3, // rows, cols 5, 5, // initialX, initialY 5, 5);// xPad, yPad // Create and set up the window. JFrame frame = new JFrame("SpringGrid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set up the content pane. panel.setOpaque(true); // content panes must be opaque frame.setContentPane(panel); // Display the window. frame.pack(); frame.setVisible(true); }
From source file:DocumentEventDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//* www . jav a2 s .com*/ private static void createAndShowGUI() { // Create and set up the window. JFrame frame = new JFrame("DocumentEventDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the content pane. JComponent newContentPane = new DocumentEventDemo(); newContentPane.setOpaque(true); // content panes must be opaque frame.setContentPane(newContentPane); // Display the window. frame.pack(); frame.setVisible(true); }
From source file:MenuDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *///from www .j a v a2 s.c om private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("MenuDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. MenuDemo demo = new MenuDemo(); frame.setJMenuBar(demo.createMenuBar()); frame.setContentPane(demo.createContentPane()); //Display the window. frame.setSize(450, 260); frame.setVisible(true); }
From source file:SwingFileChooserDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//* w w w . ja v a 2 s. c o m*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SwingFileChooserDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new SwingFileChooserDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:JWSFileChooserDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.//from w w w .j a v a2 s .com */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("JWSFileChooserDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new JWSFileChooserDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:events.ContainerEventDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.// w ww . j ava 2 s . com */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("ContainerEventDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new ContainerEventDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:FocusEventDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w w w . ja v a 2s . c o m*/ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("FocusEventDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new FocusEventDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }