类javax.swing.JInternalFrame源码实例Demo

下面列出了怎么用javax.swing.JInternalFrame的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof JInternalFrame) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JInternalFrame) {
        return !(((JInternalFrame) parent).isSelected());
    }

    return false;
}
 
源代码2 项目: visualvm   文件: WindowBuilders.java
protected JInternalFrame createInstanceImpl() {
    JInternalFrame frame = new JInternalFrame(title, resizable, closable, maximizable, iconable) {
        protected JRootPane createRootPane() {
            return _rootPane == null ? null : _rootPane.createInstance();
        }
        public void addNotify() {
            try {
                // Doesn't seem to work correctly
                setClosed(_isClosed);
                setMaximum(_isMaximum);
                setIcon(_isIcon);
                setSelected(_isSelected);
            } catch (PropertyVetoException ex) {}
        }
    };
    return frame;
}
 
源代码3 项目: dragonwell8_jdk   文件: Test6505027.java
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
源代码4 项目: mars-sim   文件: MainDesktopPane.java
@Override
	public void componentShown(ComponentEvent e) {
//		logger.config("componentShown()");
		SwingUtilities.invokeLater(() -> {
			JInternalFrame[] frames = (JInternalFrame[]) this.getAllFrames();
			for (JInternalFrame f : frames) {
				ToolWindow w = (ToolWindow) f;
				if (this.isVisible() || this.isShowing()) {
					w.update();
//					f.updateUI();
//					 SwingUtilities.updateComponentTreeUI(f);
//					f.validate();
//					f.repaint();
				}
				
				else if (!this.isShowing() && w.getToolName().equals(NavigatorWindow.NAME))
					closeToolWindow(NavigatorWindow.NAME);
			}
		});
	}
 
源代码5 项目: seaglass   文件: SeaGlassDesktopIconUI.java
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());
            }
        }
    }
}
 
源代码6 项目: JByteMod-Beta   文件: InfoPanel.java
@Override
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {
  if (!(f instanceof JInternalFrame)) {
    return;
  }
  boolean didResize = (f.getWidth() != newWidth || f.getHeight() != newHeight);
  if (!inBounds((JInternalFrame) f, newX, newY, newWidth, newHeight)) {
    Container parent = f.getParent();
    Dimension parentSize = parent.getSize();
    int boundedX = (int) Math.min(Math.max(0, newX), parentSize.getWidth() - newWidth);
    int boundedY = (int) Math.min(Math.max(0, newY), parentSize.getHeight() - newHeight);
    f.setBounds(boundedX, boundedY, newWidth, newHeight);
  } else {
    f.setBounds(newX, newY, newWidth, newHeight);
  }
  if (didResize) {
    f.validate();
  }
}
 
源代码7 项目: snap-desktop   文件: UIUtils.java
public static String getUniqueFrameTitle(final JInternalFrame[] frames, final String titleBase) {
    if (frames.length == 0) {
        return titleBase;
    }
    String[] titles = new String[frames.length];
    for (int i = 0; i < frames.length; i++) {
        JInternalFrame frame = frames[i];
        titles[i] = frame.getTitle();
    }
    if (!ArrayUtils.isMemberOf(titleBase, titles)) {
        return titleBase;
    }
    for (int i = 0; i < frames.length; i++) {
        final String title = titleBase + " (" + (i + 2) + ")";
        if (!ArrayUtils.isMemberOf(title, titles)) {
            return title;
        }
    }
    return titleBase + " (" + (frames.length + 1) + ")";
}
 
源代码8 项目: visualvm   文件: WindowBuilders.java
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JRootPane.class.getName())) {
        return new JRootPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JDesktopPane.class.getName())) {
        return new JDesktopPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JLayeredPane.class.getName())) {
        return new JLayeredPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Frame.class.getName())) {
        return new FrameBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Dialog.class.getName())) {
        return new DialogBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JInternalFrame.class.getName())) {
        return new JInternalFrameBuilder(instance, heap);
    }
    return null;
}
 
源代码9 项目: drmips   文件: FrmSimulator.java
/**
 * Restores the specified frame's bounds from the preferences.
 * @param prefPrefix The prefix of the preference.
 * @param frame The frame.
 */
private void restoreFrameBounds(String prefPrefix, JInternalFrame frame) {
	frame.setLocation(DrMIPS.prefs.getInt(prefPrefix + "_x", 0), DrMIPS.prefs.getInt(prefPrefix + "_y", 0));
	int w = DrMIPS.prefs.getInt(prefPrefix + "_w", -1);
	int h = DrMIPS.prefs.getInt(prefPrefix + "_h", -1);
	if(w > 0 && h > 0)
		frame.setSize(w, h);
	else
		frame.pack();
	try {
		if(DrMIPS.prefs.getBoolean(prefPrefix + "_max", false))
			frame.setMaximum(true);
		if(DrMIPS.prefs.getBoolean(prefPrefix + "_min", false))
			frame.setIcon(true);
	}
	catch(PropertyVetoException ex) {
		LOG.log(Level.WARNING, "failed to maximize/minimize an internal frame");
	}
}
 
源代码10 项目: seaglass   文件: ToolBarWindowIsActiveState.java
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof JInternalFrame || parent instanceof Window) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JInternalFrame) {
        return ((JInternalFrame) parent).isSelected();
    } else if (parent instanceof Window) {
        return ((Window) parent).isActive();
    }

    // Default to true.
    return true;
}
 
源代码11 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * 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;
    }
}
 
源代码12 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.getTitle()} through queue
 */
public String getTitle() {
    return (runMapping(new MapAction<String>("getTitle") {
        @Override
        public String map() {
            return ((JInternalFrame) getSource()).getTitle();
        }
    }));
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: Test6325652.java
private static JInternalFrame create(int index) {
    String text = "test" + index; // NON-NLS: frame identification
    index = index * 3 + 1;

    JInternalFrame internal = new JInternalFrame(text, true, true, true, true);
    internal.getContentPane().add(new JTextArea(text));
    internal.setBounds(10 * index, 10 * index, WIDTH, HEIGHT);
    internal.setVisible(true);
    return internal;
}
 
源代码14 项目: noa-libre   文件: OOODesktopManager.java
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) {
      }
    }
  }
}
 
源代码15 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.setFrameIcon(Icon)} through queue
 */
public void setFrameIcon(final Icon icon) {
    runMapping(new MapVoidAction("setFrameIcon") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setFrameIcon(icon);
        }
    });
}
 
源代码16 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.setClosable(boolean)} through queue
 */
public void setClosable(final boolean b) {
    runMapping(new MapVoidAction("setClosable") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setClosable(b);
        }
    });
}
 
源代码17 项目: jdk8u_jdk   文件: MetalworksFrame.java
public void openInBox() {
    JInternalFrame doc = new MetalworksInBox();
    desktop.add(doc, DOCLAYER);
    try {
        doc.setVisible(true);
        doc.setSelected(true);
    } catch (java.beans.PropertyVetoException e2) {
    }
}
 
源代码18 项目: drmips   文件: FrmSimulator.java
/**
 * Saves the specified frame's bounds to the preferences.
 * @param prefPrefix The prefix of the preference.
 * @param frame The frame.
 */
private void saveFrameBounds(String prefPrefix, JInternalFrame frame) {
	DrMIPS.prefs.putInt(prefPrefix + "_x", frame.getNormalBounds().x);
	DrMIPS.prefs.putInt(prefPrefix + "_y", frame.getNormalBounds().y);
	DrMIPS.prefs.putInt(prefPrefix + "_w", frame.getNormalBounds().width);
	DrMIPS.prefs.putInt(prefPrefix + "_h", frame.getNormalBounds().height);
	DrMIPS.prefs.putBoolean(prefPrefix + "_max", frame.isMaximum());
	DrMIPS.prefs.putBoolean(prefPrefix + "_min", frame.isIcon());
}
 
源代码19 项目: littleluck   文件: InternalFrameDemo.java
/**
 * InternalFrameDemo Constructor
 */
public InternalFrameDemo() {
    setLayout(new BorderLayout());

    // preload all the icons we need for this demo
    icon1 = resourceManager.createImageIcon("bananas.png",
            resourceManager.getString("InternalFrameDemo.bananas"));
    icon2 = resourceManager.createImageIcon("globe.png",
            resourceManager.getString("InternalFrameDemo.globe"));
    icon3 = resourceManager.createImageIcon("package.png",
            resourceManager.getString("InternalFrameDemo.package"));
    icon4 = resourceManager.createImageIcon("soccer_ball.png",
            resourceManager.getString("InternalFrameDemo.soccerball"));

    smIcon1 = resourceManager.createImageIcon("bananas_small.png",
            resourceManager.getString("InternalFrameDemo.bananas"));
    smIcon2 = resourceManager.createImageIcon("globe_small.png",
            resourceManager.getString("InternalFrameDemo.globe"));
    smIcon3 = resourceManager.createImageIcon("package_small.png",
            resourceManager.getString("InternalFrameDemo.package"));
    smIcon4 = resourceManager.createImageIcon("soccer_ball_small.png",
            resourceManager.getString("InternalFrameDemo.soccerball"));

    //<snip>Create desktop pane
    // The desktop pane will contain all the internal frames
    desktop = new JDesktopPane();
    add(desktop, BorderLayout.CENTER);
    //</snip>

    // Create the "frame maker" palette
    createInternalFramePalette();

    // Create an initial internal frame to show
    JInternalFrame frame1 = createInternalFrame(icon2, DEMO_FRAME_LAYER, 1, 1);
    frame1.setBounds(FRAME0_X, FRAME0_Y, FRAME0_WIDTH, FRAME0_HEIGHT);

}
 
源代码20 项目: dragonwell8_jdk   文件: Test6802868.java
public Test6802868(JFrame frame) {
    JDesktopPane desktop = new JDesktopPane();

    this.frame = frame;
    this.frame.add(desktop);

    this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
    this.internal.setVisible(true);

    desktop.add(this.internal);
}
 
源代码21 项目: jdk8u-jdk   文件: WindowsDesktopManager.java
public void activateFrame(JInternalFrame f) {
    JInternalFrame currentFrame = currentFrameRef != null ?
        currentFrameRef.get() : null;
    try {
        super.activateFrame(f);
        if (currentFrame != null && f != currentFrame) {
            // If the current frame is maximized, transfer that
            // attribute to the frame being activated.
            if (currentFrame.isMaximum() &&
                (f.getClientProperty("JInternalFrame.frameType") !=
                "optionDialog") ) {
                //Special case.  If key binding was used to select next
                //frame instead of minimizing the icon via the minimize
                //icon.
                if (!currentFrame.isIcon()) {
                    currentFrame.setMaximum(false);
                    if (f.isMaximizable()) {
                        if (!f.isMaximum()) {
                            f.setMaximum(true);
                        } else if (f.isMaximum() && f.isIcon()) {
                            f.setIcon(false);
                        } else {
                            f.setMaximum(false);
                        }
                    }
                }
            }
            if (currentFrame.isSelected()) {
                currentFrame.setSelected(false);
            }
        }

        if (!f.isSelected()) {
            f.setSelected(true);
        }
    } catch (PropertyVetoException e) {}
    if (f != currentFrame) {
        currentFrameRef = new WeakReference<JInternalFrame>(f);
    }
}
 
源代码22 项目: dragonwell8_jdk   文件: Test6657026.java
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();

    new JInternalFrame().setContentPane(new JPanel());
}
 
源代码23 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.getLayer()} through queue
 */
public int getLayer() {
    return (runMapping(new MapIntegerAction("getLayer") {
        @Override
        public int map() {
            return ((JInternalFrame) getSource()).getLayer();
        }
    }));
}
 
源代码24 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.setContentPane(Container)} through queue
 */
public void setContentPane(final Container container) {
    runMapping(new MapVoidAction("setContentPane") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setContentPane(container);
        }
    });
}
 
源代码25 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.isClosed()} through queue
 */
public boolean isClosed() {
    return (runMapping(new MapBooleanAction("isClosed") {
        @Override
        public boolean map() {
            return ((JInternalFrame) getSource()).isClosed();
        }
    }));
}
 
源代码26 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.moveToBack()} through queue
 */
public void moveToBack() {
    runMapping(new MapVoidAction("moveToBack") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).moveToBack();
        }
    });
}
 
源代码27 项目: openjdk-jdk9   文件: JInternalFrameOperator.java
/**
 * Maps {@code JInternalFrame.getUI()} through queue
 */
public InternalFrameUI getUI() {
    return (runMapping(new MapAction<InternalFrameUI>("getUI") {
        @Override
        public InternalFrameUI map() {
            return ((JInternalFrame) getSource()).getUI();
        }
    }));
}
 
源代码28 项目: openjdk-jdk9   文件: JComponentOperator.java
/**
 * Looks for a first window-like container.
 *
 * @return either WindowOperator of JInternalFrameOperator
 */
public ContainerOperator<?> getWindowContainerOperator() {
    Component resultComp;
    if (getSource() instanceof Window) {
        resultComp = getSource();
    } else {
        resultComp = getContainer(new ComponentChooser() {
            @Override
            public boolean checkComponent(Component comp) {
                return (comp instanceof Window
                        || comp instanceof JInternalFrame);
            }

            @Override
            public String getDescription() {
                return "";
            }
        });
    }
    ContainerOperator<?> result;
    if (resultComp instanceof Window) {
        result = new WindowOperator((Window) resultComp);
    } else {
        result = new ContainerOperator<>((Container) resultComp);
    }
    result.copyEnvironment(this);
    return result;
}
 
源代码29 项目: littleluck   文件: LuckInternalFrameUI.java
@Override
protected JComponent createNorthPane(JInternalFrame w)
{
    titlePane = new LuckInternalFrameTitlePane(w);

    return titlePane;
}
 
源代码30 项目: MtgDesktopCompanion   文件: DashBoardGUI2.java
private void initActions() {
	mntmSaveDisplay.addActionListener(ae -> {
		int i = 0;

		try {
			FileUtils.cleanDirectory(AbstractJDashlet.confdir);
		} catch (IOException e1) {
			logger.error(e1);
		}

		
		for (JInternalFrame jif : desktop.getAllFrames()) {
			i++;
			AbstractJDashlet dash = (AbstractJDashlet) jif;
			dash.setProperty("x", String.valueOf(dash.getBounds().getX()));
			dash.setProperty("y", String.valueOf(dash.getBounds().getY()));
			dash.setProperty("w", String.valueOf(dash.getBounds().getWidth()));
			dash.setProperty("h", String.valueOf(dash.getBounds().getHeight()));
			dash.setProperty("class", dash.getClass().getName());
			dash.setProperty("id", String.valueOf(i));
			File f = new File(AbstractJDashlet.confdir, i + ".conf");

			try (FileOutputStream fos = new FileOutputStream(f)) {
				dash.getProperties().store(fos, "");
				logger.trace("saving " + f + " :" + dash.getProperties());
				
			} catch (IOException e) {
				logger.error(e);
			}
		}	
		
	
		
	});
	
}
 
 类所在包
 同包方法