Example usage for javax.swing JInternalFrame dispose

List of usage examples for javax.swing JInternalFrame dispose

Introduction

In this page you can find the example usage for javax.swing JInternalFrame dispose.

Prototype

public void dispose() 

Source Link

Document

Makes this internal frame invisible, unselected, and closed.

Usage

From source file:Main.java

/**
 * Displays a specified <code>JFileChooser</code> in a JInternalFrame. <br />
 * The JInternalFrame will close when the dialog is closed. <br />
 * //from w w  w. jav a  2 s  .c o m
 * @param desktop the JDesktopPane on which to display the JFileChooser
 * @param ch the JFileChooser to display
 */
public static void showInternalFileChooser(JDesktopPane desktop, final JFileChooser ch) {
    final JInternalFrame frm = new JInternalFrame(ch.getDialogTitle());
    frm.setClosable(true);
    frm.setResizable(true);
    frm.setLayout(new BorderLayout());
    frm.add(ch, BorderLayout.CENTER);
    frm.setVisible(true);

    frm.pack();

    Dimension size = frm.getSize();
    frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2);
    desktop.add(frm, 0);

    ch.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            frm.dispose();
            ch.removeActionListener(this);
        }
    });

    try {
        frm.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {
    }
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public void dispose() {
    PreferencesManager.getSingleton().setScreenState(new WindowState(this));

    // dispose all child windows to save their screen state
    for (JInternalFrame frame : getInternalFrames()) {
        frame.dispose();
    }/*from  w  w w.  ja  v a  2 s .com*/

    scriptsPanel.dispose();

    if (haltJVMOnDispose) {
        DisposeCore.dispose();
    }

    // call super last as it calls the listeners
    super.dispose();
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public void closeDatastore() {
    setTitle("");
    tables.onDatastoreClosed();/*  w w  w .  j a v  a  2s.co m*/
    if (loaded != null) {
        loaded.getDs().removeListener(scriptManager);
        loaded.dispose();
        loaded = null;
    }
    for (JInternalFrame frame : getInternalFrames()) {

        if (ProgressFrame.class.isInstance(frame)) {
            // cancel running operations...
            ((ProgressFrame) frame).getProgressPanel().cancel();
        } else if (ScriptEditor.class.isInstance(frame) == false) {
            frame.dispose();
        }
    }
    scriptManager.datastoreStructureChanged();
    updateAppearance();
}

From source file:com.opendoorlogistics.studio.AppFrame.java

@Override
public void dispose() {
    PreferencesManager.getSingleton().setScreenState(new WindowState(this));

    // dispose all child windows to save their screen state
    for (JInternalFrame frame : desktopPane.getAllFrames()) {
        frame.dispose();
    }/*from  w  w  w .  j  a  va2  s  .  c o  m*/

    DisposeCore.dispose();

    super.dispose();
}

From source file:com.opendoorlogistics.studio.AppFrame.java

private void closeWindows() {
    for (JInternalFrame frame : desktopPane.getAllFrames()) {
        if (ScriptEditor.class.isInstance(frame)) {
            ((ScriptEditor) frame).disposeWithSavePrompt();
        } else {//from  w w  w.j  a  v a  2s  .com
            frame.dispose();
        }
    }
}

From source file:com.opendoorlogistics.studio.AppFrame.java

private void closeDatastore() {
    setTitle("");
    tables.onDatastoreClosed();/* w  w  w  .  j  av  a2s  .  com*/
    if (loaded != null) {
        loaded.getDs().removeListener(scriptManager);
        loaded.dispose();
        loaded = null;
    }
    for (JInternalFrame frame : desktopPane.getAllFrames()) {

        if (ProgressFrame.class.isInstance(frame)) {
            // cancel running operations...
            ((ProgressFrame) frame).getProgressPanel().cancel();
        } else if (ScriptEditor.class.isInstance(frame) == false) {
            frame.dispose();
        }
    }
    scriptManager.datastoreStructureChanged();
    updateAppearance();
}

From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

@Override
public void internalFrameClosed(InternalFrameEvent e) {
    decrementOpenDocuments();// ww w  . j a  v  a2s.com

    JInternalFrame internalFrame = (JInternalFrame) e.getInternalFrame();

    /* if (internalFrame instanceof WizardModeWindow) {
    setWizMode(false);
     }
    */
    InternalFrameListener[] frameListeners = internalFrame.getInternalFrameListeners();

    if (frameListeners != null) {
        for (int x = 0; x < frameListeners.length; x++) {
            internalFrame.removeInternalFrameListener(frameListeners[x]);
        }

        frameListeners = null;
    }

    decrementOpenDocuments();

    desktopPane.remove(internalFrame);

    if (internalFrame instanceof OvalEditorForm) {
        ((OvalEditorForm) internalFrame).cleanUp();
    } else if (internalFrame instanceof CPEDictionaryEditorForm) {
        ((CPEDictionaryEditorForm) internalFrame).cleanUp();
    }

    internalFrame.dispose();
    //       navPanel.clearButtons();
}

From source file:mondrian.gui.Workbench.java

private int confirmFrameClose(JInternalFrame schemaFrame, SchemaExplorer se) {
    if (se.isDirty()) {
        JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame());
        // yes=0; no=1; cancel=2
        int answer = JOptionPane.showConfirmDialog(null,
                getResourceConverter().getFormattedString("workbench.saveSchemaOnClose.alert",
                        "Save changes to {0}?", se.getSchemaFile().toString()),
                getResourceConverter().getString("workbench.saveSchemaOnClose.title", "Schema"),
                JOptionPane.YES_NO_CANCEL_OPTION);
        switch (answer) {
        case 0:/*  www. j  a v a  2 s  . c o m*/
            saveMenuItemActionPerformed(null);
            schemaWindowMap.remove(schemaFrame);
            updateMDXCatalogList();
            schemaFrame.dispose();
            windowMenu.remove(schemaMenuItem);
            break;
        case 1:
            schemaFrame.dispose();
            schemaWindowMap.remove(schemaFrame);
            windowMenu.remove(schemaMenuItem);
            break;
        case 2:
            try {
                schemaFrame.setClosed(false);
                schemaFrame.show();
            } catch (Exception ex) {
                LOGGER.error(ex);
            }
        }
        return answer;
    }
    return 3;
}

From source file:mondrian.gui.Workbench.java

private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) {
    try {/*from ww w  . j a  v a2 s.  co  m*/
        if (jdbcMetaData == null) {
            getNewJdbcMetadata();
        }

        final JInternalFrame jf = new JInternalFrame();

        jf.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title",
                "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(),
                jdbcMetaData.getJdbcConnectionUrl()));
        getNewJdbcMetadata();

        JdbcExplorer jdbce = new JdbcExplorer(jdbcMetaData, this);

        jf.getContentPane().add(jdbce);
        jf.setBounds(0, 0, 500, 480);
        jf.setClosable(true);
        jf.setIconifiable(true);
        jf.setMaximizable(true);
        jf.setResizable(true);
        jf.setVisible(true);

        // create jdbc menu item
        final javax.swing.JMenuItem jdbcMenuItem = new javax.swing.JMenuItem();
        jdbcMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.menuitem",
                "{0} JDBC Explorer", Integer.toString(windowMenuMapIndex++)));
        jdbcMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    if (jf.isIcon()) {
                        jf.setIcon(false);
                    } else {
                        jf.setSelected(true);
                    }
                } catch (Exception ex) {
                    LOGGER.error("queryMenuItem", ex);
                }
            }
        });

        jf.addInternalFrameListener(new InternalFrameAdapter() {
            public void internalFrameClosing(InternalFrameEvent e) {
                jdbcWindows.remove(jf);
                jf.dispose();
                // follow this by removing file from schemaWindowMap
                windowMenu.remove(jdbcMenuItem);
                return;
            }
        });

        desktopPane.add(jf);
        jf.setVisible(true);
        jf.show();

        try {
            jf.setSelected(true);
        } catch (Exception ex) {
            // do nothing
            LOGGER.error("newJDBCExplorerMenuItemActionPerformed.setSelected", ex);
        }

        jdbcWindows.add(jf);

        windowMenu.add(jdbcMenuItem, -1);
        windowMenu.add(jSeparator3, -1);
        windowMenu.add(cascadeMenuItem, -1);
        windowMenu.add(tileMenuItem, -1);
        windowMenu.add(minimizeMenuItem, -1);
        windowMenu.add(maximizeMenuItem, -1);
        windowMenu.add(closeAllMenuItem, -1);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.exception",
                        "Database connection not successful.\n{0}", ex.getLocalizedMessage()),
                getResourceConverter().getString("workbench.new.JDBCExplorer.exception.title",
                        "Database Connection Error"),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.error("newJDBCExplorerMenuItemActionPerformed", ex);
    }
}

From source file:mondrian.gui.Workbench.java

private void newQueryMenuItemActionPerformed(ActionEvent evt) {
    JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame());

    final JInternalFrame jf = new JInternalFrame();
    jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query"));
    QueryPanel qp = new QueryPanel(this);

    jf.getContentPane().add(qp);//from w w w.  jav  a  2 s.  c  o  m
    jf.setBounds(0, 0, 500, 480);
    jf.setClosable(true);
    jf.setIconifiable(true);
    jf.setMaximizable(true);
    jf.setResizable(true);
    jf.setVisible(true);

    desktopPane.add(jf);
    jf.show();
    try {
        jf.setSelected(true);
    } catch (Exception ex) {
        // do nothing
        LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex);
    }

    // add the mdx frame to this set of mdx frames for cascading method
    mdxWindows.add(jf);

    // create mdx menu item
    final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem();
    queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem",
            "{0} MDX", Integer.toString(windowMenuMapIndex)));
    queryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (jf.isIcon()) {
                    jf.setIcon(false);
                } else {
                    jf.setSelected(true);
                }
            } catch (Exception ex) {
                LOGGER.error("queryMenuItem", ex);
            }
        }
    });

    // disable mdx frame close operation to provide our handler
    // to remove frame object from mdxframeset before closing
    jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    jf.addInternalFrameListener(new InternalFrameAdapter() {
        public void internalFrameClosing(InternalFrameEvent e) {
            mdxWindows.remove(jf);
            jf.dispose();
            // follow this by removing file from schemaWindowMap
            windowMenu.remove(queryMenuItem);
            return;
        }
    });

    windowMenu.add(queryMenuItem, -1);
    windowMenu.add(jSeparator3, -1);
    windowMenu.add(cascadeMenuItem, -1);
    windowMenu.add(tileMenuItem, -1);
    windowMenu.add(minimizeMenuItem, -1);
    windowMenu.add(maximizeMenuItem, -1);
    windowMenu.add(closeAllMenuItem, -1);

    qp.setMenuItem(queryMenuItem);
    qp.setSchemaWindowMap(schemaWindowMap);
    qp.setWindowMenuIndex(windowMenuMapIndex++);

    if (schemaMenuItem != null) {
        qp.initConnection(schemaMenuItem.getText());
    } else {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection",
                        "No Mondrian connection. Select a Schema to connect."),
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"),
                JOptionPane.WARNING_MESSAGE);
    }
}