frame.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 649 行 · 第 1/2 页
JAVA
649 行
{ if (this.menuBar != null) this.menuBar.removeNotify(); if (menuBar != null) menuBar.addNotify(); invalidateTree (); ((FramePeer) peer).setMenuBar(menuBar); } this.menuBar = menuBar;}/** * Tests whether or not this frame is resizable. This will be * <code>true</code> by default. * * @return <code>true</code> if this frame is resizable, <code>false</code> * otherwise. */public booleanisResizable(){ return(resizable);}/** * Sets the resizability of this frame to the specified value. * * @param resizable <code>true</code> to make the frame resizable, * <code>false</code> to make it non-resizable. */public synchronized voidsetResizable(boolean resizable){ this.resizable = resizable; if (peer != null) ((FramePeer) peer).setResizable(resizable);}/** * Returns the cursor type of the cursor for this window. This will * be one of the constants in this class. * * @return The cursor type for this frame. * * @deprecated Use <code>Component.getCursor()</code> instead. */public intgetCursorType(){ return(getCursor().getType());}/** * Sets the cursor for this window to the specified type. The specified * type should be one of the constants in this class. * * @param type The cursor type. * * @deprecated Use <code>Component.setCursor(Cursor)</code> instead. */public voidsetCursor(int type){ setCursor(new Cursor(type));}/** * Removes the specified component from this frame's menu. * * @param menu The menu component to remove. */public voidremove(MenuComponent menu){ menuBar.remove(menu);}/** * Notifies this frame that it should create its native peer. */private static void fireDummyEvent(){ EventQueue.invokeLater(new Runnable() { public void run() { // Do nothing here. } });}public voidaddNotify(){ if (menuBar != null) menuBar.addNotify(); if (peer == null) peer = getToolkit ().createFrame (this); // We now know there's a Frame (us) with a live peer, so we can start the // fundamental queue and dispatch thread, by inserting a dummy event. if (parent != null && parent.isDisplayable()) fireDummyEvent(); super.addNotify();}public void removeNotify(){ if (menuBar != null) menuBar.removeNotify(); super.removeNotify(); // By now we've been disconnected from the peer, and the peer set to // null. This is formally the same as saying "we just became // un-displayable", so we wake up the event queue with a dummy event to // see if it's time to shut down. fireDummyEvent();} /** * Returns a debugging string describing this window. * * @return A debugging string describing this window. */ protected String paramString () { String title = getTitle (); String resizable = ""; if (isResizable ()) resizable = ",resizable"; String state = ""; switch (getState ()) { case NORMAL: state = ",normal"; break; case ICONIFIED: state = ",iconified"; break; case MAXIMIZED_BOTH: state = ",maximized-both"; break; case MAXIMIZED_HORIZ: state = ",maximized-horiz"; break; case MAXIMIZED_VERT: state = ",maximized-vert"; break; } return super.paramString () + ",title=" + title + resizable + state; }private static ArrayList weakFrames = new ArrayList();private static void noteFrame(Frame f){ weakFrames.add(new WeakReference(f));}public static Frame[] getFrames(){ int n = 0; synchronized (weakFrames) { Iterator i = weakFrames.iterator(); while (i.hasNext()) { WeakReference wr = (WeakReference) i.next(); if (wr.get() != null) ++n; } if (n == 0) return new Frame[0]; else { Frame[] frames = new Frame[n]; n = 0; i = weakFrames.iterator(); while (i.hasNext()) { WeakReference wr = (WeakReference) i.next(); if (wr.get() != null) frames[n++] = (Frame) wr.get(); } return frames; } }} public void setState (int state) { int current_state = getExtendedState (); if (state == NORMAL && (current_state & ICONIFIED) != 0) setExtendedState (current_state | ICONIFIED); if (state == ICONIFIED && (current_state & ~ICONIFIED) == 0) setExtendedState (current_state & ~ICONIFIED); } public int getState () { /* FIXME: State might have changed in the peer... Must check. */ return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL; } /** * @since 1.4 */ public void setExtendedState (int state) { this.state = state; } /** * @since 1.4 */ public int getExtendedState () { return state; } /** * @since 1.4 */ public void setMaximizedBounds (Rectangle maximizedBounds) { this.maximizedBounds = maximizedBounds; } /** * Returns the maximized bounds of this frame. * * @return the maximized rectangle, may be null. * * @since 1.4 */ public Rectangle getMaximizedBounds () { return maximizedBounds; } /** * Returns whether this frame is undecorated or not. * * @since 1.4 */ public boolean isUndecorated () { return undecorated; } /** * Disables or enables decorations for this frame. This method can only be * called while the frame is not displayable. * * @exception IllegalComponentStateException If this frame is displayable. * * @since 1.4 */ public void setUndecorated (boolean undecorated) { if (!isDisplayable ()) throw new IllegalComponentStateException (); this.undecorated = undecorated; } /** * Generate a unique name for this frame. * * @return A unique name for this frame. */ String generateName () { return "frame" + getUniqueLong (); } private static synchronized long getUniqueLong () { return next_frame_number++; } protected class AccessibleAWTFrame extends AccessibleAWTWindow { public AccessibleRole getAccessibleRole() { return AccessibleRole.FRAME; } public AccessibleStateSet getAccessibleState() { AccessibleStateSet states = super.getAccessibleStateSet(); if (isResizable()) states.add(AccessibleState.RESIZABLE); if ((state & ICONIFIED) != 0) states.add(AccessibleState.ICONIFIED); return states; } } /** * Gets the AccessibleContext associated with this <code>Frame</code>. * The context is created, if necessary. * * @return the associated context */ public AccessibleContext getAccessibleContext() { /* Create the context if this is the first request */ if (accessibleContext == null) accessibleContext = new AccessibleAWTFrame(); return accessibleContext; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?