📄 component.java
字号:
}public Color getForeground () { return fgClr;}public Graphics getGraphics () { if ( (flags & IS_ADD_NOTIFIED) != 0 ) return NativeGraphics.getClippedGraphics( null, this, 0, 0, 0, 0, width, height, false); else return null;}public int getHeight() { return height;}public Locale getLocale () { if (locale != null) { return (locale); } else if (parent != null) { return (parent.getLocale()); } else { return (Locale.getDefault()); }}public Point getLocation () { return location();}public Point getLocationOnScreen () { // this has to be resolved for Applets int u=0, v=0; for ( Component c=this; c != null; c=c.parent ) { u += c.x; v += c.y; } return new Point( u, v);}public Dimension getMaximumSize() { return Toolkit.singleton.getScreenSize();}// Subclasses that guarantee to always completely paint their contents should override this method and return true. All of the "heavyweight" AWT components are opaque.public boolean isOpaque() { return false;}public Dimension getMinimumSize() { return minimumSize();}public String getName () { return (name == null) ? getClass().getName() : name;}Pointer getNativeData () { return null; // no nativeData, all lightweight}public Container getParent() { return parent;}/** * @deprecated, should not be called. */public ComponentPeer getPeer() { // this is just a dummy, i.e. we share a single object that can be used // ONLY to "(getPeer() != null)" check if we already passed addNotify() return ((flags & IS_ADD_NOTIFIED) != 0) ? DUMMY_PEER : null;}public Dimension getPreferredSize() { return (preferredSize());}/** * @deprecated, use getSize() * this is never called automatically, override getSize in derived classes * to change the default behavior */public Dimension getSize () { return size();}/** * this is a stub only for now */public void setDropTarget(DropTarget dt) {// TODO this is only a stub }/** * this is a stub only for now */public DropTarget getDropTarget() {// TODO this is only a stub return null;}public Toolkit getToolkit () { return Toolkit.singleton;}Component getToplevel () { Component c; for ( c=this; !(c instanceof Window) && c != null; c= c.parent ); return c;}final public Object getTreeLock() { return treeLock;}public int getWidth() { return width;}public int getX() { return x;}public int getY() { return y;}/** * @deprecated */public boolean gotFocus(Event evt, Object what) { return (false);}/** * @deprecated */public boolean handleEvent(Event evt) { switch (evt.id) { case Event.ACTION_EVENT: return (action(evt, evt.arg)); case Event.GOT_FOCUS: return (gotFocus(evt, evt.arg)); case Event.KEY_PRESS: return (keyDown(evt, evt.key)); case Event.KEY_RELEASE: return (keyUp(evt, evt.key)); case Event.LOST_FOCUS: return (lostFocus(evt, evt.arg)); case Event.MOUSE_DOWN: return (mouseDown(evt, evt.x, evt.y)); case Event.MOUSE_DRAG: return (mouseDrag(evt, evt.x, evt.y)); case Event.MOUSE_ENTER: return (mouseEnter(evt, evt.x, evt.y)); case Event.MOUSE_EXIT: return (mouseExit(evt, evt.x, evt.y)); case Event.MOUSE_MOVE: return (mouseMove(evt, evt.x, evt.y)); case Event.MOUSE_UP: return (mouseUp(evt, evt.x, evt.y)); default: return (false); }}public void hide () { // DEP this should be in setVisible !! But we have to keep it here // for compatibility reasons (Swing etc.) if ( (flags & IS_VISIBLE) != 0 ) { flags &= ~IS_VISIBLE; // if we are a toplevel, the native window manager will take care // of repainting, otherwise we have to do it explicitly if ( (parent != null) && ((parent.flags & IS_LAYOUTING) == 0) ) { if ( (flags & IS_PARENT_SHOWING) != 0) { parent.repaint( x, y, width, height); } if ( (parent.flags & IS_VALID) != 0 ) parent.invalidate(); } if ( (cmpListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ){ Toolkit.eventQueue.postEvent( ComponentEvt.getEvent( this, ComponentEvent.COMPONENT_HIDDEN)); } if ( linkedGraphs != null ) updateLinkedGraphics(); }}public boolean imageUpdate (Image img, int infoflags, int x, int y, int width, int height ) { if ( (infoflags & (ALLBITS | FRAMEBITS)) != 0 ) { if ( (flags & IS_SHOWING) == IS_SHOWING ) repaint(); } // We return false if we're no longer interested in updates.This is *NOT* // what is said in the Addison-Wesley documentation, but is what is says // in the JDK javadoc documentation. if ( (infoflags & (ALLBITS | ABORT | ERROR)) != 0 ) { return (false); } else { return (true); }}/** * @deprecated */public boolean inside ( int x, int y ) { if ( (flags & IS_SHOWING) != IS_SHOWING ) return false; if ( (x < 0) || (y < 0) || (x > width) || (y > height) ) return false;/*** // If we want to deal with components being bigger than their parents, // we have to check for parent.contains(), too. However, this is not // done by the JDK, and we therefor skip it for now x += this.x; y += this.y; for ( Container c=parent; c!= null; x += c.x, y += c.y, c = c.parent ) { if ( (x < 0) || (y < 0) || (x > c.width) || (y > c.height) ) return false; }***/ return true;}boolean intersects ( Component c ) { return intersects( c.x, c.y, c.width, c.height);}boolean intersects ( Rectangle r ) { return intersects( r.x, r.y, r.width, r.height);}boolean intersects ( int u, int v, int w, int h ) { if ( (x > (u + w)) || (y > (v + h)) || (u > (x + width)) || (v > (y + height)) ) return false; else return true;}public void invalidate () { // invalidation means invalid yourself *and* all your parents (if they // arent't already) synchronized ( treeLock ) { if ( (flags & IS_VALID) != 0 ) { flags &= ~IS_VALID; // maybe, it's overloaded (we have to sacrifice speed for compat, here) // parent can't be null, because we can't get valid without being addNotifyed if ( (parent.flags & IS_VALID) != 0 ) parent.invalidate(); } }}/** * PersonalJava 1.1 method */public boolean isDoubleBuffered() { return (false);}public boolean isEnabled () { return (eventMask & AWTEvent.DISABLED_MASK) == 0;}public boolean isFocusTraversable() { return (((flags & (IS_SHOWING|IS_NATIVE_LIKE)) == (IS_SHOWING|IS_NATIVE_LIKE)) && ((eventMask & AWTEvent.DISABLED_MASK) == 0));}// TODO this is was copied from isFocusTraversable, may be wrong.public boolean isFocusable() { return (((flags & (IS_SHOWING|IS_NATIVE_LIKE)) == (IS_SHOWING|IS_NATIVE_LIKE)) && ((eventMask & AWTEvent.DISABLED_MASK) == 0));}// TODO this is a stub onlypublic void setFocusable(boolean focusable) {}// TODO this is a stub onlypublic boolean isFocusOwner() { return true;}/** * @deprecated */public boolean hasFocus() { return isFocusOwner();}public boolean isShowing () { // compare the costs of this with the standard upward iteration return ((flags & (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED)) == (IS_PARENT_SHOWING | IS_VISIBLE | IS_ADD_NOTIFIED));}public boolean isValid () { return ((flags & IS_VALID) != 0);}public boolean isVisible () { return ((flags & IS_VISIBLE) != 0);}/** * @deprecated */public boolean keyDown(Event evt, int key) { return (false);}/** * @deprecated */public boolean keyUp(Event evt, int key) { return (false);}/** * @deprecated, use doLayout() */public void layout() {}synchronized void linkGraphics ( NativeGraphics g ) { GraphicsLink li, last, next; // do some cleanup as we go for ( li = linkedGraphs, last = null; li != null; ){ if ( li.get() == null ){ // recycle this one, its Graphics has been collected if ( last == null ){ linkedGraphs = li.next; } else { last.next = li.next; } next = li.next; li = next; } else { last = li; li = li.next; } } // References are immutable, i.e. we can't cache them for later re-use. // Since we cache Graphics objects, the best we can do is to use GraphicsLinks // objects exclusively (sort of per-Graphics cache) if ( g.link == null ){ li = new GraphicsLink( g); g.link = li; } else { li = g.link; } // set the target/link state (we don't want to use common Graphics objects // with all that fuzz which is just needed for linked Graphicses) li.xOffset = g.xOffset; li.yOffset = g.yOffset; li.next = linkedGraphs; li.width = width; li.height = height; li.isVisible = ((flags & IS_SHOWING) == IS_SHOWING); g.target = this; linkedGraphs = li;}public void list() { list(System.out);}public void list(PrintStream out) { list(out, 0);}public void list(PrintStream out, int indent) { list (new PrintWriter(out), indent);}public void list(PrintWriter out) { list (out, 0);}public void list(PrintWriter out, int indent) { for (int i = indent; i > 0; --i) { out.print(' '); } out.println(toString()); out.flush();}/** * @deprecated, use getComponentAt(int, int) */public Component locate(int x, int y) { // don't do a direct comparison here since transparent Components resolve contains() return (contains( x, y) ? this : null);}/** * @deprecated, use getLocation() */public Point location() { return new Point( x, y);}/** * @deprecated */public boolean lostFocus(Event evt, Object what) { return (false);}/** * @deprecated, use getMinimumSize() */public Dimension minimumSize() { return new Dimension( width, height);}/** * @deprecated */public boolean mouseDown(Event evt, int x, int y) { return (false);}/** * @deprecated */public boolean mouseDrag(Event evt, int x, int y) { return (false);}/** * @deprecated */public boolean mouseEnter(Event evt, int x, int y) { return (false);}/** * @deprecated */public boolean mouseExit(Event evt, int x, int y) { return (false);}/** * @deprecated */public boolean mouseMove(Event evt, int x, int y) { return (false);}/** * @deprecated
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -