Example usage for javax.swing JFrame setContentPane

List of usage examples for javax.swing JFrame setContentPane

Introduction

In this page you can find the example usage for javax.swing JFrame setContentPane.

Prototype

@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.")
public void setContentPane(Container contentPane) 

Source Link

Document

Sets the contentPane property.

Usage

From source file:org.pentaho.reporting.engine.classic.core.util.ComponentDrawable.java

/**
 * Creates a new ComponentDrawable with the given Frame as peer-supply.
 *
 * @param peerSupply//  ww  w .java  2 s  . c o  m
 *          the frame that should be used as peer-source.
 */
public ComponentDrawable(final JFrame peerSupply) {
    if (peerSupply == null) {
        throw new NullPointerException();
    }
    this.peerSupply = peerSupply;
    this.contentPane = new JPanel();
    this.contentPane.setLayout(null);
    peerSupply.setContentPane(contentPane);
    this.runnable = new PainterRunnable();
    this.preferredSizeRunnable = new PreferredSizeRunnable();
    this.sizeRunnable = new DefinedSizeRunnable();
}

From source file:Provider.GoogleMapsStatic.TestUI.SampleApp.java

private void _displayImgInFrame() {

    final JFrame frame = new JFrame("Google Static Map");
    GUIUtils.setAppIcon(frame, "71.png");
    frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JLabel imgLbl = new JLabel(new ImageIcon(_img));
    imgLbl.setToolTipText(MessageFormat.format("<html>Image downloaded from URI<br>size: w={0}, h={1}</html>",
            _img.getWidth(), _img.getHeight()));
    imgLbl.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }/*from  w w w  .j a v  a 2  s  . c om*/

        public void mousePressed(MouseEvent e) {
            frame.dispose();
        }

        public void mouseReleased(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }
    });

    frame.setContentPane(imgLbl);
    frame.pack();

    GUIUtils.centerOnScreen(frame);
    frame.setVisible(true);
}

From source file:Provider.GoogleMapsStatic.TestUI.SampleApp.java

private void _displayRespStrInFrame() {

    final JFrame frame = new JFrame("Google Static Map - Error");
    GUIUtils.setAppIcon(frame, "69.png");
    frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JTextArea response = new JTextArea(_respStr, 25, 80);
    response.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }// ww  w .  ja  v  a 2  s .  co m

        public void mousePressed(MouseEvent e) {
            frame.dispose();
        }

        public void mouseReleased(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }
    });

    frame.setContentPane(new JScrollPane(response));
    frame.pack();

    GUIUtils.centerOnScreen(frame);
    frame.setVisible(true);
}

From source file:psidev.psi.mi.validator.client.gui.DragAndDropValidator.java

/**
 * Runs a sample program that shows dropped files
 *///from w w w. j av a 2  s .  co m
public static void main(String[] args) throws FileNotFoundException, ValidatorException {

    // TODO ValidatorException should popup instead of appearing in the background (ie. console)

    if (args.length == 0 || args.length > 2) {
        System.err.println("Usage: DragAndDropValidator <validator_config_file> [log level]");
        System.exit(1);
    }

    // setup Logging.
    Log4jConfigurator.configure();

    String configFile = args[0];
    final MessageLevel level;
    if (args.length == 2) {
        level = MessageLevel.forName(args[1]);
        log.info("User requested log level: " + level);
    } else {
        level = MessageLevel.WARN; // default
        log.info("Message Level set to default: " + level);
    }

    FileInputStream configStream = new FileInputStream(configFile);
    Validator validator = null;
    try {
        validator = new MiValidator(configStream, null, null);
    } catch (OntologyLoaderException e) {
        throw new ValidatorException("", e);
    } finally {
        try {
            configStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    //Create and set up the window.
    final JFrame frame = new javax.swing.JFrame("PSI-MI 2.5 Drag & Drop Validator");

    //Create and set up the content pane.
    final ValidatorTable validatorTable = new ValidatorTable(validator);
    validatorTable.setOpaque(true); //content panes must be opaque
    frame.setContentPane(validatorTable);

    // Handle the dropped files
    PrintStream out = null; // could be System.out
    new DragAndDropComponent(out, validatorTable, new FilesDroppedListener() {

        public void filesDropped(java.io.File[] files) {

            for (int i = 0; i < files.length; i++) {

                ValidatorTableRow row = new ValidatorTableRow(files[i], level, true);

                validatorTable.addTableRow(row);
            } // end for: through each dropped file
        } // end filesDropped
    }); // end FileDrop.Listener

    // Set up menus
    setupMenus(frame, validator, validatorTable, level);

    // Set up the window.
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(100, 100, 50, 50); // the size of the frame is defined by its internal component.

    frame.pack();
    frame.setVisible(true);
}

From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.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 2 s . c o m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Map by BLAST Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new PICRBLASTDemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}