📄 component.java
字号:
}public Color getBackground () { return background;/* if ( background != null ) return background; for ( Component c=parent; c != null; c = c.parent ) { if ( c.background != null ) return c.bgClr; } // even though not in the specs, some apps (e.g. swing) rely on the // JDK behavior of returning 'null' if there isn't a parent yet return null; //return Color.white;*/}public Rectangle getBounds () { return bounds();}// TODO this is a tentative implementationpublic Rectangle getBounds (Rectangle rv) { if (rv == null) return bounds(); rv.x = x; rv.y = y; rv.width= width; rv.height = height; return rv;}ClassProperties getClassProperties () { // direct Component / Container derived classes can't use old events // (they had no protected ctor in 1.0.2) return ClassAnalyzer.analyzeProcessEvent( getClass(), false);} /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value */ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value */ protected void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value */ protected void firePropertyChange(String propertyName, int oldValue, int newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, byte oldValue, byte newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Byte(oldValue), new Byte(newValue)); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, char oldValue, char newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Character(oldValue), new Character(newValue)); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, short oldValue, short newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Short(oldValue), new Short(newValue)); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, long oldValue, long newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Long(oldValue), new Long(newValue)); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, float oldValue, float newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Float(oldValue), new Float(newValue)); } /** * Report a change in a bound property to any registered property listeners. * * @param propertyName the property that changed * @param oldValue the old property value * @param newValue the new property value * * @since 1.5 */ public void firePropertyChange(String propertyName, double oldValue, double newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Double(oldValue), new Double(newValue)); }public ColorModel getColorModel() { return Toolkit.getDefaultToolkit().getColorModel();}public Component getComponentAt ( Point pt ) { return getComponentAt( pt.x, pt.y );}public Component getComponentAt ( int x, int y ) { return locate( x, y);}public Cursor getCursor() { return cursor;}public Font getFont () { return font;}public FontMetrics getFontMetrics ( Font font ) { return FontMetrics.getFontMetrics( font);}public Color getForeground () { return foreground;}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();} /** * Tests if this component is opaque. All "heavyweight" (natively-drawn) * components are opaque. A component is opaque if it draws all pixels in * the bounds; a lightweight component is partially transparent if it lets * pixels underneath show through. Subclasses that guarantee that all pixels * will be drawn should override this. * * @return true if this is opaque * @see #isLightweight() * @since 1.2 */ public boolean isOpaque() { return ! isLightweight(); } /** * Return whether the component is lightweight. That means the component has * no native peer, but is displayable. This applies to subclasses of * Component not in this package, such as javax.swing. * * Kaffe AWT: we have no peer, so we just choose to return true. * * @return true if the component has a lightweight peer * @see #isDisplayable() * @since 1.2 */ public boolean isLightweight() { return true; }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;}/*** Returns the toolkit in use for this component. The toolkit is associated * with the frame this component belongs to. * * @return the toolkit for this component */public Toolkit getToolkit(){ if (peer != null) { Toolkit tk = peer.getToolkit(); if (tk != null) return tk; } // Get toolkit for lightweight component. if (parent != null) return parent.getToolkit(); return Toolkit.getDefaultToolkit();}Window getToplevel () { Component c; for ( c=this; !(c instanceof Window) && c != null; c= c.parent ); return (Window)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 ( (componentListener != null) || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ){ Toolkit.eventQueue.postEvent( ComponentEvt.getEvent( this, ComponentEvent.COMPONENT_HIDDEN)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -