⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toplevel.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public static boolean isMDIMode() { return (mode == UserInterfaceMain.Mode.MDI); }	/**	 * Method to return messagesWindow window.	 * The messagesWindow window runs along the bottom.	 * @return the messagesWindow window.	 */	public static MessagesWindow getMessagesWindow() { return messagesWindow; }    /**	 * Method to return status bar associated with this TopLevel.	 * @return the status bar associated with this TopLevel.	 */	public StatusBar getStatusBar() { return sb; }    /**     * Get the tool bar associated with this TopLevel     * @return the ToolBar.     */    public ToolBar getToolBar() { return toolBar; }    /** Get the Menu Bar. Unfortunately named because getMenuBar() already exists */    public EMenuBar.Instance getTheMenuBar() { return menuBar; }    /** Get the Menu Bar. Unfortunately named because getMenuBar() already exists */    public EMenuBar getEMenuBar() { return menuBar.getMenuBarGroup(); }    /**     * Method to return the speed of double-clicks (in milliseconds).     * @return the speed of double-clicks (in milliseconds).     */    public static int getDoubleClickSpeed() { return doubleClickDelay; }    /**	 * Method to return the size of the screen that Electric is on.	 * @return the size of the screen that Electric is on.	 */	public static Dimension getScreenSize()	{		if (isMDIMode())		{			Rectangle bounds = topLevel.getBounds();			Rectangle dBounds = desktop.getBounds();			if (dBounds.width != 0 && dBounds.height != 0)			{				return new Dimension(dBounds.width, dBounds.height);			}			return new Dimension(bounds.width-8, bounds.height-96);		}		return new Dimension(scrnSize);	}	/**	 * Method to add an internal frame to the desktop.	 * This only makes sense in MDI mode, where the desktop has multiple subframes.	 * @param jif the internal frame to add.	 */	public static void addToDesktop(JInternalFrame jif)	{        if (desktop.isVisible() && !SwingUtilities.isEventDispatchThread())            SwingUtilities.invokeLater(new ModifyToDesktopSafe(jif, true)); else            	(new ModifyToDesktopSafe(jif, true)).run();    }	/**	 * Method to remove an internal frame from the desktop.	 * This only makes sense in MDI mode, where the desktop has multiple subframes.	 * @param jif the internal frame to remove.	 */	public static void removeFromDesktop(JInternalFrame jif)	{        if (desktop.isVisible() && !SwingUtilities.isEventDispatchThread())            SwingUtilities.invokeLater(new ModifyToDesktopSafe(jif, false)); else            	(new ModifyToDesktopSafe(jif, false)).run();    }    private static class ModifyToDesktopSafe implements Runnable    {        private JInternalFrame jif;        private boolean add;        private ModifyToDesktopSafe(JInternalFrame jif, boolean add) { this.jif = jif;  this.add = add; }        public void run()        {        	if (add)        	{	            desktop.add(jif);		        jif.show();        	} else        	{                desktop.remove(jif);        	}        }    }	public static JDesktopPane getDesktop() { return desktop; }	public static Cursor getCurrentCursor() { return cursor; }	public static synchronized void setCurrentCursor(Cursor cursor)	{        TopLevel.cursor = cursor;        setCurrentCursorPrivate(cursor);    }    private static synchronized void setCurrentCursorPrivate(Cursor cursor)    {        if (mode == UserInterfaceMain.Mode.MDI) {            JFrame jf = TopLevel.getCurrentJFrame();            if (jf != null) jf.setCursor(cursor);        }        for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); )        {            WindowFrame wf = it.next();            wf.setCursor(cursor);        }	}        public static synchronized List<ToolBar> getToolBars() {        ArrayList<ToolBar> toolBars = new ArrayList<ToolBar>();        if (mode == UserInterfaceMain.Mode.MDI) {            toolBars.add(topLevel.getToolBar());        } else {            for (Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) {                WindowFrame wf = it.next();                toolBars.add(wf.getFrame().getToolBar());            }        }        return toolBars;    }    public static synchronized List<EMenuBar.Instance> getMenuBars() {        ArrayList<EMenuBar.Instance> menuBars = new ArrayList<EMenuBar.Instance>();        if (mode == UserInterfaceMain.Mode.MDI) {            if (topLevel != null)                menuBars.add(topLevel.getTheMenuBar());        } else {            for (Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) {                WindowFrame wf = it.next();                menuBars.add(wf.getFrame().getTheMenuBar());            }        }        return menuBars;    }    /**     * The busy cursor overrides any other cursor.     * Call clearBusyCursor to reset to last set cursor     */    public static synchronized void setBusyCursor(boolean on) {        if (on) {            if (!busyCursorOn)                setCurrentCursorPrivate(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));            busyCursorOn = true;        } else {            // if the current cursor is a busy cursor, set it to the last normal cursor            if (busyCursorOn)                setCurrentCursorPrivate(getCurrentCursor());            busyCursorOn = false;        }    }	/**	 * Method to return the current JFrame on the screen.	 * @return the current JFrame.	 */	public static TopLevel getCurrentJFrame()	{		if (isMDIMode()) return topLevel;		WindowFrame wf = WindowFrame.getCurrentWindowFrame();        if (wf == null) return null;		return wf.getFrame();	}//	/**//	 * Method to set the WindowFrame associated with this top-level window.//	 * This only makes sense for SDI applications where a WindowFrame is inside of a TopLevel.//	 * @param wf the WindowFrame to associatd with this.//	 *///	public void setWindowFrame(WindowFrame wf) { this.wf = wf; }        /**     * Method called when done with this Frame.  Both the menuBar     * and toolBar have persistent state in static hash tables to maintain     * consistency across different menu bars and tool bars in SDI mode.     * Those references must be nullified for garbage collection to reclaim     * that memory.  This is really for SDI mode, because in MDI mode the      * TopLevel is only closed on exit, and all the application memory will be freed.     * <p>     * NOTE: JFrame does not get garbage collected after dispose() until     * some arbitrary point later in time when the garbage collector decides     * to free it.     */    public void finished()    {        //System.out.println(this.getClass()+" being disposed of");        // clean up menubar        setJMenuBar(null);        // TODO: figure out why Swing still sends events to finished menuBars        menuBar.finished(); menuBar = null;        // clean up toolbar        Container container = getContentPane();        if (container != null) container.remove(toolBar);//        getContentPane().remove(toolBar);        toolBar.finished(); toolBar = null;        // clean up scroll bar        if (container != null) container.remove(sb);        sb.finished(); sb = null;        /* Note that this gets called from WindowFrame, and            WindowFrame has a reference to EditWindow, so            WindowFrame will call wnd.finished(). */        // dispose of myself        super.dispose();    }    /**     * Method to return a list of possible window areas.     * On MDI systems, there is just one window areas.     * On SDI systems, there is one window areas for each display head on the computer.     * @return an array of window areas.     */    public static Rectangle [] getWindowAreas()	{		Rectangle [] areas;		if (isMDIMode())		{			TopLevel tl = getCurrentJFrame();			Dimension sz = tl.getContentPane().getSize();			areas = new Rectangle[1];			areas[0] = new Rectangle(0, 0, sz.width, sz.height);		} else		{			areas = getDisplays();		}		return areas;	}    /**     * Method to return a list of display areas, one for each display head on the computer.     * @return an array of display areas.     */    public static Rectangle [] getDisplays()	{		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();		GraphicsDevice [] gs = ge.getScreenDevices();		Rectangle [] areas = new Rectangle[gs.length];		for (int j = 0; j < gs.length; j++)		{			GraphicsDevice gd = gs[j];			GraphicsConfiguration gc = gd.getDefaultConfiguration();			areas[j] = gc.getBounds();		}		return areas;	}	/**     * Print error message <code>msg</code> and stack trace     * if <code>print</code> is true.     * @param print print error message and stack trace if true     * @param msg error message to print     */    public static void printError(boolean print, String msg)    {        if (print) {            Throwable t = new Throwable(msg);            System.out.println(t.toString());            ActivityLogger.logException(t);                    }    }	private static class ReshapeComponentAdapter extends ComponentAdapter	{		public void componentMoved (ComponentEvent e) { saveLocation(e); }		public void componentResized (ComponentEvent e) { saveLocation(e); }		private void saveLocation(ComponentEvent e)		{			TopLevel frame = (TopLevel)e.getSource();			Rectangle bounds = frame.getBounds();			cacheWindowLoc.setString(bounds.getMinX() + "," + bounds.getMinY() + " " +				bounds.getWidth() + "x" + bounds.getHeight());		}	}	/**	 * This class handles close events for JFrame objects (used in MDI mode to quit).	 */	private static class WindowsEvents extends WindowAdapter	{		WindowsEvents() { super(); }		public void windowClosing(WindowEvent evt) {            FileMenu.quitCommand();        }	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -