Example usage for javax.swing JRootPane FILE_CHOOSER_DIALOG

List of usage examples for javax.swing JRootPane FILE_CHOOSER_DIALOG

Introduction

In this page you can find the example usage for javax.swing JRootPane FILE_CHOOSER_DIALOG.

Prototype

int FILE_CHOOSER_DIALOG

To view the source code for javax.swing JRootPane FILE_CHOOSER_DIALOG.

Click Source Link

Document

Constant used for the windowDecorationStyle property.

Usage

From source file:com.googlecode.vfsjfilechooser2.VFSJFileChooser.java

/**
 * Creates and returns a new <code>JDialog</code> wrapping
 * <code>this</code> centered on the <code>parent</code>
 * in the <code>parent</code>'s frame.
 * This method can be overriden to further manipulate the dialog,
 * to disable resizing, set the location, etc. Example:
 * <pre>//from w  w  w.j  ava2s  . c o  m
 *     class MyFileChooser extends VFSJFileChooser {
 *         protected JDialog createDialog(Component parent) throws HeadlessException {
 *             JDialog dialog = super.createDialog(parent);
 *             dialog.setLocation(300, 200);
 *             dialog.setResizable(false);
 *             return dialog;
 *         }
 *     }
 * </pre>
 *
 * @param   parent  the parent component of the dialog;
 *                  can be <code>null</code>
 * @return a new <code>JDialog</code> containing this instance
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since 1.4
 */
protected JDialog createDialog(Component parent) throws HeadlessException {
    String title = getUI().getDialogTitle(this);
    putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, title);

    Window window = null;

    try {
        window = SwingUtilities.getWindowAncestor(parent);
    } catch (Exception ex) {
    }

    if (window == null) {
        if (parent instanceof Window) {
            window = (Window) parent;
        } else {
            window = SHARED_FRAME;
        }

        dialog = new JDialog((Frame) window, title, true);
    }

    else if (window instanceof Frame) {
        dialog = new JDialog((Frame) window, title, true);
    } else {
        dialog = new JDialog((Dialog) window, title, true);
    }

    dialog.setComponentOrientation(this.getComponentOrientation());

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();

        if (supportsWindowDecorations) {
            dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
        }
    }

    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    return dialog;
}

From source file:org.executequery.components.FileChooserDialog.java

protected JDialog createDialog(Component parent) throws HeadlessException {

    Frame frame = parent instanceof Frame ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    String title = getUI().getDialogTitle(this);

    JDialog dialog = new JDialog(frame, title, true);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    setPreferredSize(new Dimension(700, getPreferredSize().height));

    // add any custom panel
    if (customPanel != null) {
        contentPane.add(customPanel, BorderLayout.SOUTH);
    }//from  ww  w  . j a v a  2s . c  o  m

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();

        if (supportsWindowDecorations) {
            dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
        }

    }

    setFileView(new DefaultFileView());
    dialog.pack();

    dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize()));
    return dialog;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setLayout(new BorderLayout(0, 0));
    JPanel p = new JPanel();
    p.setBorder(null);/*from  ww  w.j a  v a2  s  .  co  m*/
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(buildQuotaPane());
    p.add(table);
    tabbedPane.add("Files to import", p);
    tabbedPane.add("Options", buildOptionsPane());

    double[][] tablePanelDesign = { { TableLayout.PREFERRED, 10, 5, TableLayout.FILL },
            { TableLayout.PREFERRED, TableLayout.FILL } };
    JPanel tablePanel = new JPanel(new TableLayout(tablePanelDesign));
    tablePanel.add(table.buildControls(), "0, 1, LEFT, CENTER");
    tablePanel.add(tabbedPane, "2, 1, 3, 1");
    int plugin = ImporterAgent.runAsPlugin();
    JSplitPane pane;
    if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        JLabel label = UIUtilities.setTextFont("Select where to import the image(s).");
        panel.add(UIUtilities.buildComponentPanel(label));
        panel.add(locationDialog.getContentPane());
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, tablePanel);
    } else {
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chooser, tablePanel);
    }

    JPanel mainPanel = new JPanel();
    double[][] mainPanelDesign = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } };
    mainPanel.setLayout(new TableLayout(mainPanelDesign));
    mainPanel.setBackground(UIUtilities.BACKGROUND);
    mainPanel.add(pane, "0, 1");

    this.add(mainPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel();
    controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));

    // Lays out the buttons.
    JPanel bar = new JPanel();
    bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS));
    bar.add(buildToolBarLeft());
    bar.add(buildToolBarRight());
    controls.add(new JSeparator());
    controls.add(bar);

    add(controls, BorderLayout.SOUTH);
    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations)
            getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
    }
}