Java Code Examples for javax.swing.JInternalFrame#JDesktopIcon
The following examples show how to use
javax.swing.JInternalFrame#JDesktopIcon .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeaGlassDesktopPaneUI.java From seaglass with Apache License 2.0 | 8 votes |
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { c = c.getParent(); if (c != null) { c.add(f); if (f.isMaximum()) { int w = c.getWidth(); int h = c.getHeight() - taskBar.getHeight(); if (f.getWidth() != w || f.getHeight() != h) { setBoundsForFrame(f, 0, 0, w, h); } } if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } } }
Example 2
Source File: SeaGlassDesktopIconUI.java From seaglass with Apache License 2.0 | 6 votes |
public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) { if (SeaGlassLookAndFeel.shouldUpdateStyle(evt)) { updateStyle((JInternalFrame.JDesktopIcon) evt.getSource()); } } else if (evt.getSource() instanceof JInternalFrame) { JInternalFrame frame = (JInternalFrame) evt.getSource(); if (iconPane instanceof JToggleButton) { JToggleButton button = (JToggleButton) iconPane; String prop = evt.getPropertyName(); if (prop == "title") { button.setText((String) evt.getNewValue()); } else if (prop == "frameIcon") { button.setIcon((Icon) evt.getNewValue()); } else if (prop == JInternalFrame.IS_ICON_PROPERTY || prop == JInternalFrame.IS_SELECTED_PROPERTY) { button.setSelected(!frame.isIcon() && frame.isSelected()); } } } }
Example 3
Source File: SeaGlassDesktopPaneUI.java From seaglass with Apache License 2.0 | 6 votes |
public void componentAdded(ContainerEvent e) { if (e.getChild() instanceof JInternalFrame) { JInternalFrame f = (JInternalFrame) e.getChild(); JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); for (Component comp : getComponents()) { if (comp == desktopIcon) { // We have it already return; } } add(desktopIcon); f.addComponentListener(this); if (getComponentCount() == 1) { adjustSize(); } } }
Example 4
Source File: SeaGlassDesktopPaneUI.java From seaglass with Apache License 2.0 | 6 votes |
protected void uninstallDefaults() { SeaGlassContext context = getContext(desktop, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; if (taskBar != null) { for (Component comp : taskBar.getComponents()) { JInternalFrame.JDesktopIcon desktopIcon = (JInternalFrame.JDesktopIcon) comp; taskBar.remove(desktopIcon); desktopIcon.setPreferredSize(null); JInternalFrame f = desktopIcon.getInternalFrame(); if (f.isIcon()) { desktop.add(desktopIcon); } f.removeComponentListener(taskBar); } desktop.remove(taskBar); taskBar = null; } }
Example 5
Source File: NimbusDefaults.java From JDKSourceCode1.8 with MIT License | 5 votes |
private boolean matches(Component c, int partIndex) { if (partIndex < 0) return true; if (c == null) return false; //only get here if partIndex > 0 and c == null String name = c.getName(); if (parts[partIndex].named && parts[partIndex].s.equals(name)) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (!parts[partIndex].named) { //if c is not named, and parts[partIndex] has an expected class //type registered, then check to make sure c is of the //right type; Class clazz = parts[partIndex].c; if (clazz != null && clazz.isAssignableFrom(c.getClass())) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (clazz == null && registeredRegions.containsKey(parts[partIndex].s)) { Region r = registeredRegions.get(parts[partIndex].s); Component parent = r.isSubregion() ? c : c.getParent(); //special case the JInternalFrameTitlePane, because it //doesn't fit the mold. very, very funky. if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null && parent instanceof JInternalFrame.JDesktopIcon) { JInternalFrame.JDesktopIcon icon = (JInternalFrame.JDesktopIcon) parent; parent = icon.getInternalFrame(); } //it was the name of a region. So far, so good. Recurse. return matches(parent, partIndex - 1); } } return false; }
Example 6
Source File: SeaGlassInternalFrameTitlePane.java From seaglass with Apache License 2.0 | 5 votes |
/** * Uninstall the defaults. */ public void uninstallDefaults() { SeaGlassContext context = getContext(this, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; JInternalFrame.JDesktopIcon di = frame.getDesktopIcon(); if (di != null && di.getComponentPopupMenu() == systemPopupMenu) { // Release link to systemMenu from the JInternalFrame di.setComponentPopupMenu(null); } }
Example 7
Source File: SeaGlassDesktopPaneUI.java From seaglass with Apache License 2.0 | 5 votes |
protected void installDefaults() { updateStyle(desktop); if (UIManager.getBoolean("InternalFrame.useTaskBar")) { taskBar = new TaskBar(); for (Component comp : desktop.getComponents()) { JInternalFrame.JDesktopIcon desktopIcon; if (comp instanceof JInternalFrame.JDesktopIcon) { desktopIcon = (JInternalFrame.JDesktopIcon) comp; } else if (comp instanceof JInternalFrame) { desktopIcon = ((JInternalFrame) comp).getDesktopIcon(); } else { continue; } // Move desktopIcon from desktop to taskBar if (desktopIcon.getParent() == desktop) { desktop.remove(desktopIcon); } if (desktopIcon.getParent() != taskBar) { taskBar.add(desktopIcon); desktopIcon.getInternalFrame().addComponentListener(taskBar); } } taskBar.setBackground(desktop.getBackground()); desktop.add(taskBar, new Integer(JLayeredPane.PALETTE_LAYER.intValue() + 1)); if (desktop.isShowing()) { taskBar.adjustSize(); } } }
Example 8
Source File: OOODesktopManager.java From noa-libre with GNU Lesser General Public License v2.1 | 5 votes |
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { f.setBounds(oldBounds.remove(f)); //XXX //c.add(f); //XXX // If the frame is to be restored to a maximized state make // sure it still fills the whole desktop. if (f.isMaximum()) { Rectangle desktopBounds = c.getBounds(); if (f.getWidth() != desktopBounds.width || f.getHeight() != desktopBounds.height) { setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height); } } removeIconFor(f); if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } }
Example 9
Source File: NimbusDefaults.java From Java8CN with Apache License 2.0 | 5 votes |
private boolean matches(Component c, int partIndex) { if (partIndex < 0) return true; if (c == null) return false; //only get here if partIndex > 0 and c == null String name = c.getName(); if (parts[partIndex].named && parts[partIndex].s.equals(name)) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (!parts[partIndex].named) { //if c is not named, and parts[partIndex] has an expected class //type registered, then check to make sure c is of the //right type; Class clazz = parts[partIndex].c; if (clazz != null && clazz.isAssignableFrom(c.getClass())) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (clazz == null && registeredRegions.containsKey(parts[partIndex].s)) { Region r = registeredRegions.get(parts[partIndex].s); Component parent = r.isSubregion() ? c : c.getParent(); //special case the JInternalFrameTitlePane, because it //doesn't fit the mold. very, very funky. if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null && parent instanceof JInternalFrame.JDesktopIcon) { JInternalFrame.JDesktopIcon icon = (JInternalFrame.JDesktopIcon) parent; parent = icon.getInternalFrame(); } //it was the name of a region. So far, so good. Recurse. return matches(parent, partIndex - 1); } } return false; }
Example 10
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static JInternalFrame findOne(ContainerOperator<?> cont, String text, int index) { Component source = waitComponent(cont, new JInternalFrameByTitleFinder(text, cont.getComparator()), index); if (source instanceof JInternalFrame) { return (JInternalFrame) source; } else if (source instanceof JInternalFrame.JDesktopIcon) { return ((JInternalFrame.JDesktopIcon) source).getInternalFrame(); } else { throw (new TimeoutExpiredException("No internal frame was found")); } }
Example 11
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Waits JInternalframe in container. * * @param cont Container to search component in. * @param chooser a component chooser specifying searching criteria. * @param index Ordinal component index. * @return JInternalframe instance. * */ public static JInternalFrame waitJInternalFrame(final Container cont, final ComponentChooser chooser, final int index) { Component res = waitComponent(cont, new JInternalFrameFinder(chooser), index); if (res instanceof JInternalFrame) { return (JInternalFrame) res; } else if (res instanceof JInternalFrame.JDesktopIcon) { return ((JInternalFrame.JDesktopIcon) res).getInternalFrame(); } else { throw (new TimeoutExpiredException(chooser.getDescription())); } }
Example 12
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Searches JInternalframe in container. * * @param cont Container to search component in. * @param chooser a component chooser specifying searching criteria. * @param index Ordinal component index. * @return JInternalframe instance or null if component was not found. */ public static JInternalFrame findJInternalFrame(Container cont, ComponentChooser chooser, int index) { Component res = findComponent(cont, new JInternalFrameFinder(chooser), index); if (res instanceof JInternalFrame) { return (JInternalFrame) res; } else if (res instanceof JInternalFrame.JDesktopIcon) { return ((JInternalFrame.JDesktopIcon) res).getInternalFrame(); } else { return null; } }
Example 13
Source File: Canvas.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Get any panel this {@code Canvas} is displaying. * * @return A {@code Component} the {@code Canvas} is * displaying, or null if none found. */ public Component getShowingSubPanel() { for (Component c : getComponents()) { if (c instanceof ToolBoxFrame) { continue; } if (c instanceof JInternalFrame) { return c; } else if (c instanceof JInternalFrame.JDesktopIcon) { return c; } } return null; }
Example 14
Source File: NimbusDefaults.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private boolean matches(Component c, int partIndex) { if (partIndex < 0) return true; if (c == null) return false; //only get here if partIndex > 0 and c == null String name = c.getName(); if (parts[partIndex].named && parts[partIndex].s.equals(name)) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (!parts[partIndex].named) { //if c is not named, and parts[partIndex] has an expected class //type registered, then check to make sure c is of the //right type; Class clazz = parts[partIndex].c; if (clazz != null && clazz.isAssignableFrom(c.getClass())) { //so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (clazz == null && registeredRegions.containsKey(parts[partIndex].s)) { Region r = registeredRegions.get(parts[partIndex].s); Component parent = r.isSubregion() ? c : c.getParent(); //special case the JInternalFrameTitlePane, because it //doesn't fit the mold. very, very funky. if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null && parent instanceof JInternalFrame.JDesktopIcon) { JInternalFrame.JDesktopIcon icon = (JInternalFrame.JDesktopIcon) parent; parent = icon.getInternalFrame(); } //it was the name of a region. So far, so good. Recurse. return matches(parent, partIndex - 1); } } return false; }
Example 15
Source File: OOODesktopManager.java From noa-libre with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void iconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon; Container c = f.getParent(); JDesktopPane d = f.getDesktopPane(); boolean findNext = f.isSelected(); desktopIcon = f.getDesktopIcon(); if (!wasIcon(f)) { Rectangle r = getBoundsForIconOf(f); desktopIcon.setBounds(r.x, r.y, r.width, r.height); setWasIcon(f, Boolean.TRUE); } if (c == null) { return; } if (c instanceof JLayeredPane) { JLayeredPane lp = (JLayeredPane) c; int layer = JLayeredPane.getLayer(f); JLayeredPane.putLayer(desktopIcon, layer); } // If we are maximized we already have the normal bounds recorded // don't try to re-record them, otherwise we incorrectly set the // normal bounds to maximized state. if (!f.isMaximum()) { f.setNormalBounds(f.getBounds()); } //c.remove(f); XXX oldBounds.put(f, f.getBounds()); //XXX f.setBounds(0, 0, 0, 0); //XXX c.add(desktopIcon); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); try { f.setSelected(false); } catch (PropertyVetoException e2) { } // Get topmost of the remaining frames if (findNext) { activateNextFrame(c); } }
Example 16
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean checkComponent(Component comp) { return ((comp instanceof JInternalFrame || comp instanceof JInternalFrame.JDesktopIcon) && sf.checkComponent(comp)); }
Example 17
Source File: SeaGlassLookAndFeel.java From seaglass with Apache License 2.0 | 4 votes |
/** * Internal method to determine whether a component matches a part of a * style. Recurses to do the work. * * @param c the component to test against the current style * hierarchy. * @param partIndex the index of the part of the hierarchy. * * @return {@code true} if the component matches the style, * {@code false} otherwise. */ private boolean matches(Component c, int partIndex) { if (partIndex < 0) return true; if (c == null) return false; // only get here if partIndex > 0 and c == null String name = c.getName(); if (parts[partIndex].named && parts[partIndex].s.equals(name)) { // so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (!parts[partIndex].named) { // If c is not named, and parts[partIndex] has an expected class // type registered, then check to make sure c is of the right // type; Class clazz = parts[partIndex].c; if (clazz != null && clazz.isAssignableFrom(c.getClass())) { // so far so good, recurse return matches(c.getParent(), partIndex - 1); } else if (clazz == null && registeredRegions.containsKey(parts[partIndex].s)) { Region r = registeredRegions.get(parts[partIndex].s); Component parent = r.isSubregion() ? c : c.getParent(); // special case the JInternalFrameTitlePane, because it // doesn't fit the mold. very, very funky. if (r == Region.INTERNAL_FRAME_TITLE_PANE && parent != null && parent instanceof JInternalFrame.JDesktopIcon) { JInternalFrame.JDesktopIcon icon = (JInternalFrame.JDesktopIcon) parent; parent = icon.getInternalFrame(); } else if (r == Region.INTERNAL_FRAME_TITLE_PANE && c instanceof SeaGlassTitlePane) { // Also special case the title pane. Its parent is the // layered pane and hasn't yet been assigned, but we // want it to behave as if its parent is an internal // frame. if (partIndex <= 0 || (parts[partIndex - 1].c != null && parts[partIndex - 1].c.isAssignableFrom(JInternalFrame.class))) { return true; } } // it was the name of a region. So far, so good. Recurse. return matches(parent, partIndex - 1); } } return false; }
Example 18
Source File: JInternalFrameOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Constructs JDesktopIconOperator. * * @param b a component */ public JDesktopIconOperator(JInternalFrame.JDesktopIcon b) { super(b); setOutput(JemmyProperties.getCurrentOutput()); setTimeouts(JemmyProperties.getCurrentTimeouts()); }