List of usage examples for javax.swing JInternalFrame isIcon
boolean isIcon
To view the source code for javax.swing JInternalFrame isIcon.
Click Source Link
From source file:GUIUtils.java
public static void moveToFront(final JInternalFrame fr) { if (fr != null) { processOnSwingEventThread(new Runnable() { public void run() { fr.moveToFront();//www . j a v a 2 s . c o m fr.setVisible(true); try { fr.setSelected(true); if (fr.isIcon()) { fr.setIcon(false); } fr.setSelected(true); } catch (PropertyVetoException ex) { } fr.requestFocus(); } }); } }
From source file:SampleDesktop.java
public void actionPerformed(ActionEvent ev) { // How many frames do we have? JInternalFrame[] allframes = desk.getAllFrames(); int count = allframes.length; if (count == 0) return;// www . j ava2 s.c o m // Determine the necessary grid size int sqrt = (int) Math.sqrt(count); int rows = sqrt; int cols = sqrt; if (rows * cols < count) { cols++; if (rows * cols < count) { rows++; } } // Define some initial values for size & location. Dimension size = desk.getSize(); int w = size.width / cols; int h = size.height / rows; int x = 0; int y = 0; // Iterate over the frames, deiconifying any iconified frames and then // relocating & resizing each. for (int i = 0; i < rows; i++) { for (int j = 0; j < cols && ((i * cols) + j < count); j++) { JInternalFrame f = allframes[(i * cols) + j]; if (!f.isClosed() && f.isIcon()) { try { f.setIcon(false); } catch (PropertyVetoException ignored) { } } desk.getDesktopManager().resizeFrame(f, x, y, w, h); x += w; } y += h; // start the next row x = 0; } }
From source file:InternalFrameTest.java
/** * Cascades the non-iconified internal frames of the desktop. *//* ww w . ja v a 2 s. co m*/ public void cascadeWindows() { int x = 0; int y = 0; int width = desktop.getWidth() / 2; int height = desktop.getHeight() / 2; for (JInternalFrame frame : desktop.getAllFrames()) { if (!frame.isIcon()) { try { // try to make maximized frames resizable; this might be vetoed frame.setMaximum(false); frame.reshape(x, y, width, height); x += frameDistance; y += frameDistance; // wrap around at the desktop edge if (x + width > desktop.getWidth()) x = 0; if (y + height > desktop.getHeight()) y = 0; } catch (PropertyVetoException e) { } } } }
From source file:InternalFrameTest.java
/** * Tiles the non-iconified internal frames of the desktop. */// ww w .j a v a2s . c o m public void tileWindows() { // count frames that aren't iconized int frameCount = 0; for (JInternalFrame frame : desktop.getAllFrames()) if (!frame.isIcon()) frameCount++; if (frameCount == 0) return; int rows = (int) Math.sqrt(frameCount); int cols = frameCount / rows; int extra = frameCount % rows; // number of columns with an extra row int width = desktop.getWidth() / cols; int height = desktop.getHeight() / rows; int r = 0; int c = 0; for (JInternalFrame frame : desktop.getAllFrames()) { if (!frame.isIcon()) { try { frame.setMaximum(false); frame.reshape(c * width, r * height, width, height); r++; if (r == rows) { r = 0; c++; if (c == cols - extra) { // start adding an extra row rows++; height = desktop.getHeight() / rows; } } } catch (PropertyVetoException e) { } } } }
From source file:com.tag.FramePreferences.java
@SuppressWarnings("serial") public FramePreferences(final JInternalFrame frame, String pathName) { setFrame(new Frame() { @Override/*from ww w . jav a 2 s .co m*/ public synchronized int getExtendedState() { if (frame.isMaximum()) { return Frame.MAXIMIZED_BOTH; } else if (frame.isIcon()) { return Frame.ICONIFIED; } else { return Frame.NORMAL; } } @Override public synchronized void setExtendedState(int state) { try { switch (state) { case Frame.MAXIMIZED_HORIZ: case Frame.MAXIMIZED_VERT: case Frame.MAXIMIZED_BOTH: frame.setMaximum(true); break; case Frame.ICONIFIED: frame.setIcon(true); break; case Frame.NORMAL: frame.setIcon(false); frame.setMaximum(false); break; } } catch (PropertyVetoException e) { e.printStackTrace(); } } @Override public synchronized void addWindowStateListener(final WindowStateListener l) { final Frame source = this; frame.addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameIconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED)); } @Override public void internalFrameDeiconified(InternalFrameEvent e) { l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED)); } }); } @Override public synchronized void removeWindowStateListener(WindowStateListener l) { super.removeWindowStateListener(l); } @Override public GraphicsConfiguration getGraphicsConfiguration() { return frame.getGraphicsConfiguration(); } public Point getLocation() { return frame.getLocation(); } @Override public void setLocation(Point p) { frame.setLocation(p); } @Override public Dimension getSize() { return frame.getSize(); } @Override public void setSize(Dimension size) { frame.setSize(size); } @Override public synchronized void addComponentListener(ComponentListener l) { frame.addComponentListener(l); } @Override public synchronized void removeComponentListener(ComponentListener l) { frame.addComponentListener(l); } }); setPathName(pathName); }
From source file:mondrian.gui.Workbench.java
private void minimizeMenuItemActionPerformed(ActionEvent evt) { try {//from w w w . j a v a2 s .c o m for (JInternalFrame sf : getAllFrames()) { if (sf != null && !sf.isIcon()) { sf.setIcon(true); } } } catch (Exception ex) { LOGGER.error("minimizeMenuItemActionPerformed", ex); // do nothing } }
From source file:mondrian.gui.Workbench.java
private void cascadeMenuItemActionPerformed(ActionEvent evt) { try {/*from ww w . java2 s . c om*/ int sfi = 1; for (JInternalFrame sf : getAllFrames()) { if (sf != null && !sf.isIcon()) { sf.setMaximum(false); sf.setLocation(30 * sfi, 30 * sfi); sf.moveToFront(); sf.setSelected(true); sfi++; } } } catch (Exception ex) { LOGGER.error("cascadeMenuItemActionPerformed", ex); // do nothing } }
From source file:mondrian.gui.Workbench.java
private void tileMenuItemActionPerformed(ActionEvent evt) { final Dimension dsize = desktopPane.getSize(); final int desktopW = (int) dsize.getWidth(); final int desktopH = (int) dsize.getHeight(); final int darea = desktopW * desktopH; final double eacharea = darea / (schemaWindowMap.size() + mdxWindows.size() + jdbcWindows.size()); final int wh = (int) Math.sqrt(eacharea); try {/*from w w w . ja v a 2 s . co m*/ int x = 0, y = 0; for (JInternalFrame sf : getAllFrames()) { if (sf != null && !sf.isIcon()) { sf.setMaximum(false); sf.moveToFront(); if (x >= desktopW || (desktopW - x) * wh < eacharea / 2) { // move to next row of windows y += wh; x = 0; } int sfwidth = ((x + wh) < desktopW ? wh : desktopW - x); int sfheight = ((y + wh) < desktopH ? wh : desktopH - y); sf.setBounds(x, y, sfwidth, sfheight); x += sfwidth; } } } catch (Exception ex) { LOGGER.error("tileMenuItemActionPerformed", ex); // do nothing } }
From source file:mondrian.gui.Workbench.java
private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) { try {/*from w w w .j a v a 2 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 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 a v a 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); } }