List of usage examples for javax.swing JInternalFrame setClosable
@BeanProperty(preferred = true, description = "Indicates whether this internal frame can be closed.") public void setClosable(boolean b)
JInternalFrame
can be closed by some user action. 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 ww.jav a 2s .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:Main.java
/** * Creates (and displays) a JInternalFrame for a specified component. <br /> * The size of the JInternalFrame will be <code>frameSize</code>. <br /> * The frame is <i>just</i> closeable. <br /> * //from w ww. ja v a2 s.c o m * @param desktop the JDesktopPane * @param comp the component to display in the created frame * @param title the title of the frame * @param frameSize the size of the frame * @return the created and displayed frame */ public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title, Dimension frameSize) { JInternalFrame frm = new JInternalFrame(title); frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(comp, BorderLayout.CENTER); frm.setSize(frameSize); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); desktop.add(frm, 0); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } return frm; }
From source file:Main.java
/** * Creates (and displays) a JInternalFrame for a specified component. <br /> * The size of the JInternalFrame will be setted with calling <code>pack()</code>. <br /> * //from w ww . j av a 2 s .com * @param desktop the JDesktopPane * @param comp the component to display in the created frame * @param title the title of the frame * @param frameSize the size of the frame * @return the created and displayed frame */ public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title) { JInternalFrame frm = new JInternalFrame(title); frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(comp, BorderLayout.CENTER); desktop.add(frm, 0); frm.pack(); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } return frm; }
From source file:Main.java
/** * Shows a specified JInternalFrame in the middle of the specified JDesktopPane. <br /> * The size of the JInternalFrame will be <code>frameSize</code>. <br /> * The frame is <i>just</i> closeable. <br /> * //from w w w . ja v a 2 s . co m * @param desktop the JDesktopPane * @param frm the JInternalFrame * @param content the component which will be added to the JInternalFrame * @param frameSize the size of the JInternalFrame */ public static void showInternalFrame(JDesktopPane desktop, JInternalFrame frm, JComponent content, Dimension frameSize) { frm.setClosable(true); frm.setLayout(new BorderLayout()); frm.add(content, BorderLayout.CENTER); frm.setSize(frameSize); frm.setVisible(true); Dimension size = frm.getSize(); frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2); desktop.add(frm, 0); try { frm.setSelected(true); } catch (java.beans.PropertyVetoException e) { } }
From source file:guineu.modules.dataanalysis.PCA.PCADataset.java
public void run() { setStatus(TaskStatus.PROCESSING);//from w w w . ja va2s .co m logger.info("Computing projection plot"); double[][] rawData = new double[selectedSamples.length][selectedRows.length]; for (int rowIndex = 0; rowIndex < selectedRows.length; rowIndex++) { PeakListRow peakListRow = selectedRows[rowIndex]; for (int fileIndex = 0; fileIndex < selectedSamples.length; fileIndex++) { String rawDataFile = selectedSamples[fileIndex]; Object p = peakListRow.getPeak(rawDataFile); try { rawData[fileIndex][rowIndex] = (Double) p; } catch (Exception e) { // e.printStackTrace(); } } } this.progress = 0.25f; int numComponents = xAxisPC; if (yAxisPC > numComponents) { numComponents = yAxisPC; } PCA pca = new PCA(selectedSamples.length, selectedRows.length); Matrix X = new Matrix(rawData, selectedSamples.length, selectedRows.length); String[] rowNames = new String[selectedRows.length]; for (int j = 0; j < selectedRows.length; j++) { rowNames[j] = selectedRows[j].getName(); } X = pca.center(X); X = pca.scale(X); pca.nipals(X, this.selectedSamples, rowNames, this.components); mainComponents = pca.getPCs(); Collections.sort(mainComponents); if (status == TaskStatus.CANCELED) { return; } this.progress = 0.75f; for (PrincipleComponent comp : mainComponents) { this.totalVariation += comp.eigenValue; } if (mainComponents.size() > yAxisPC - 1) { component1Coords = mainComponents.get(xAxisPC - 1).eigenVector; component2Coords = mainComponents.get(yAxisPC - 1).eigenVector; Desktop desktop = GuineuCore.getDesktop(); ProjectionPlotWindow newFrame = new ProjectionPlotWindow(this.datasetTitle, this, parameters); desktop.addInternalFrame(newFrame); if (this.showLoadings) { ChartPanel loadings = pca.loadingsplot(this.getXLabel(), this.getYLabel()); JInternalFrame frame = new JInternalFrame(); frame.setTitle("Principal Components Analysis: Loadings"); frame.setResizable(true); frame.setClosable(true); frame.setMaximizable(true); frame.add(loadings, BorderLayout.CENTER); frame.setPreferredSize(new Dimension(700, 500)); frame.pack(); desktop.addInternalFrame(frame); } } this.progress = 1.0f; setStatus(TaskStatus.FINISHED); logger.info("Finished computing projection plot."); }
From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java
private void showInDialog(String title, Component ancestor) { // final JDialog dialog; // if (ancestor instanceof JFrame) { // dialog = new JDialog((JFrame)ancestor); // }/*from www . j a va2 s . c o m*/ // else if (ancestor instanceof JDialog) { // dialog = new JDialog((JDialog)ancestor); // } // else if (ancestor == null) { // dialog = new JDialog(); // } // else { // throw new RuntimeException(); // } JInternalFrame dialog = new JInternalFrame(title); // dialog.setTitle(client.url() + dbPath); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); // dialog.setModal(false); dialog.getContentPane().add(ancestor); dialog.setSize(400, 300); // dialog.setLocationRelativeTo(ancestor); dialog.setResizable(true); dialog.setClosable(true); dialog.setIconifiable(true); dialog.setMaximizable(true); getDesktopPane().add(dialog); try { dialog.setMaximum(true); } catch (PropertyVetoException e) { e.printStackTrace(); } dialog.setVisible(true); }
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);// w ww. j ava 2 s. c om 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); } }
From source file:mondrian.gui.Workbench.java
private void aboutMenuItemActionPerformed(ActionEvent evt) { try {/*from w w w.ja v a 2 s . co m*/ JEditorPane jEditorPane = new JEditorPane( myClassLoader.getResource(getResourceConverter().getGUIReference("version")).toString()); jEditorPane.setEditable(false); JScrollPane jScrollPane = new JScrollPane(jEditorPane); JPanel jPanel = new JPanel(); jPanel.setLayout(new java.awt.BorderLayout()); jPanel.add(jScrollPane, java.awt.BorderLayout.CENTER); JInternalFrame jf = new JInternalFrame(); jf.setTitle("About"); jf.getContentPane().add(jPanel); Dimension screenSize = this.getSize(); int aboutW = 400; int aboutH = 300; int width = (screenSize.width / 2) - (aboutW / 2); int height = (screenSize.height / 2) - (aboutH / 2) - 100; jf.setBounds(width, height, aboutW, aboutH); jf.setClosable(true); desktopPane.add(jf); jf.setVisible(true); jf.show(); } catch (Exception ex) { LOGGER.error("aboutMenuItemActionPerformed", ex); } }
From source file:mondrian.gui.Workbench.java
private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) { try {//ww w . j a v a2 s . c o 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 openSchemaFrame(File file, boolean newFile) { try {/*from www .ja v a 2 s.c o m*/ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (!newFile) { // check if file not already open if (checkFileOpen(file)) { return; } // check if schema file exists if (!file.exists()) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.not.found", "{0} File not found.", file.getAbsolutePath()), getResourceConverter().getString("workbench.open.schema.not.found.title", "Alert"), JOptionPane.WARNING_MESSAGE); return; } // check if file is writable if (!file.canWrite()) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.not.writeable", "{0} is not writeable.", file.getAbsolutePath()), getResourceConverter().getString("workbench.open.schema.not.writeable.title", "Alert"), JOptionPane.WARNING_MESSAGE); return; } checkSchemaFile(file); } final JInternalFrame schemaFrame = new JInternalFrame(); schemaFrame.setTitle(getResourceConverter().getFormattedString("workbench.open.schema.title", "Schema - {0}", file.getName())); getNewJdbcMetadata(); schemaFrame.getContentPane().add(new SchemaExplorer(this, file, jdbcMetaData, newFile, schemaFrame)); String errorOpening = ((SchemaExplorer) schemaFrame.getContentPane().getComponent(0)).getErrMsg(); if (errorOpening != null) { JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("workbench.open.schema.error", "Error opening schema - {0}.", errorOpening), getResourceConverter().getString("workbench.open.schema.error.title", "Error"), JOptionPane.ERROR_MESSAGE); schemaFrame.setClosed(true); return; } schemaFrame.setBounds(0, 0, 1000, 650); schemaFrame.setClosable(true); schemaFrame.setIconifiable(true); schemaFrame.setMaximizable(true); schemaFrame.setResizable(true); schemaFrame.setVisible(true); desktopPane.add(schemaFrame, javax.swing.JLayeredPane.DEFAULT_LAYER); schemaFrame.show(); schemaFrame.setMaximum(true); displayWarningOnFailedConnection(); final javax.swing.JMenuItem schemaMenuItem = new javax.swing.JMenuItem(); schemaMenuItem.setText(windowMenuMapIndex++ + " " + file.getName()); schemaMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { if (schemaFrame.isIcon()) { schemaFrame.setIcon(false); } else { schemaFrame.setSelected(true); } } catch (Exception ex) { LOGGER.error("schemaMenuItem", ex); } } }); windowMenu.add(schemaMenuItem, 0); windowMenu.setEnabled(true); windowMenu.add(jSeparator3, -1); windowMenu.add(cascadeMenuItem, -1); windowMenu.add(tileMenuItem, -1); windowMenu.add(minimizeMenuItem, -1); windowMenu.add(maximizeMenuItem, -1); windowMenu.add(closeAllMenuItem, -1); // add the file details in menu map schemaWindowMap.put(schemaFrame, schemaMenuItem); updateMDXCatalogList(); schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); schemaFrame.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); int response = confirmFrameClose(schemaFrame, se); if (response == 3) { // not dirty if (se.isNewFile()) { se.getSchemaFile().delete(); } // default case for no save and not dirty schemaWindowMap.remove(schemaFrame); updateMDXCatalogList(); schemaFrame.dispose(); windowMenu.remove(schemaMenuItem); } } } }); schemaFrame.setFocusable(true); schemaFrame.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); // update view menu based on schemaframe who gained // focus viewXmlMenuItem.setSelected(se.isEditModeXML()); } } public void focusLost(FocusEvent e) { if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0); // update view menu based on viewXmlMenuItem.setSelected(se.isEditModeXML()); } } }); viewXmlMenuItem.setSelected(false); } catch (Exception ex) { LOGGER.error("openSchemaFrame", ex); } finally { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }