📄 component.java
字号:
/** * The associated graphics configuration. * * @since 1.4 */ transient GraphicsConfiguration graphicsConfig; /** * The buffer strategy for repainting. * * @since 1.4 */ transient BufferStrategy bufferStrategy; /** * true if requestFocus was called on this component when its * top-level ancestor was not focusable. */ private transient FocusEvent pendingFocusRequest = null;static class TreeLock{}/* * JDK serialization. * While this is serializing something like what JDK expects, we don't handle the more complex * things like Properties or popupMenus yet (because I'm not sure how to convert what we do * into what they expect). */// private Color bgColor;// private java.beans.PropertyChangeSupport changeSupport;// private int componentSerializedDataVersion;// private Cursor cursor;// private boolean enabled;// private long eventMask;// private Font font;// private Color foreground;// private boolean hasFocus;// private int height;// private boolean isPacked;// private Locale locale;// private Dimension minSize;// private String name;// private boolean nameExplicitlySet;// private boolean newEventsOnly;// private Font peerFont;// private Vector popups;// private Dimension prefSize;// private boolean valid;// private boolean visible;// private int width;// private int x;// private int y;// // private void readDefaultObject() {// setBackground(bgColor);// setCursor(cursor);// setEnabled(enabled);// enableEvents(eventMask);// setFont(font);// setForeground(foreground);// setSize(width, height);// setLocale(locale);// setName(name);// setLocation(x, y);// if (valid) {// validate();// }// else {// invalidate();// }// if (visible) {// show();// }// else {// hide();// }// }// // private void writeDefaultObject() {// bgColor = Component.this.background;// changeSupport = null;// componentSerializedDataVersion = 0;// cursor = Component.this.cursor;// enabled = isEnabled();// eventMask = Component.this.eventMask;// font = Component.this.font;// foreground = Component.this.foreground;// hasFocus = false;// height = Component.this.height;// isPacked = false;// locale = Component.this.locale;// minSize = getMinimumSize();// name = Component.this.name;// nameExplicitlySet = true;// newEventsOnly = !getClassProperties().useOldEvents;// peerFont = Component.this.font;// popups = null;// prefSize = getPreferredSize();// valid = isValid();// visible = isVisible();// width = Component.this.width;// x = Component.this.x;// y = Component.this.y;// }// protected Component () { cursor = Cursor.defaultCursor;}/** * @deprecated */public boolean action(Event evt, Object what) { return (false);}public void add ( PopupMenu menu ) { if ( menu.parent != null ) menu.parent.remove( menu); if ( (flags & IS_ADD_NOTIFIED) > 0 ) { menu.parent = this; menu.owner = this; menu.addNotify(); } if ( popup == null ) popup = menu; else { popup.addSeparator(); popup.addAll( menu); }} /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see ComponentEvent * @see #removeComponentListener(ComponentListener) * @see #getComponentListeners() * @since 1.1 */ public synchronized void addComponentListener(ComponentListener listener) { componentListener = AWTEventMulticaster.add(componentListener, listener); if (componentListener != null) enableEvents(AWTEvent.COMPONENT_EVENT_MASK); } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see ComponentEvent * @see #addComponentListener(ComponentListener) * @see #getComponentListeners() * @since 1.1 */ public synchronized void removeComponentListener(ComponentListener listener) { componentListener = AWTEventMulticaster.remove(componentListener, listener); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addComponentListener(ComponentListener) * @see #removeComponentListener(ComponentListener) * @since 1.4 */ public synchronized ComponentListener[] getComponentListeners() { return (ComponentListener[]) AWTEventMulticaster.getListeners(componentListener, ComponentListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see FocusEvent * @see #removeFocusListener(FocusListener) * @see #getFocusListeners() * @since 1.1 */ public synchronized void addFocusListener(FocusListener listener) { focusListener = AWTEventMulticaster.add(focusListener, listener); if (focusListener != null) enableEvents(AWTEvent.FOCUS_EVENT_MASK); } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see FocusEvent * @see #addFocusListener(FocusListener) * @see #getFocusListeners() * @since 1.1 */ public synchronized void removeFocusListener(FocusListener listener) { focusListener = AWTEventMulticaster.remove(focusListener, listener); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addFocusListener(FocusListener) * @see #removeFocusListener(FocusListener) * @since 1.4 */ public synchronized FocusListener[] getFocusListeners() { return (FocusListener[]) AWTEventMulticaster.getListeners(focusListener, FocusListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see HierarchyEvent * @see #removeHierarchyListener(HierarchyListener) * @see #getHierarchyListeners() * @since 1.3 */ public synchronized void addHierarchyListener(HierarchyListener listener) { hierarchyListener = AWTEventMulticaster.add(hierarchyListener, listener); if (hierarchyListener != null) enableEvents(AWTEvent.HIERARCHY_EVENT_MASK); } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see HierarchyEvent * @see #addHierarchyListener(HierarchyListener) * @see #getHierarchyListeners() * @since 1.3 */ public synchronized void removeHierarchyListener(HierarchyListener listener) { hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, listener); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addHierarchyListener(HierarchyListener) * @see #removeHierarchyListener(HierarchyListener) * @since 1.4 */ public synchronized HierarchyListener[] getHierarchyListeners() { return (HierarchyListener[]) AWTEventMulticaster.getListeners(hierarchyListener, HierarchyListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see HierarchyEvent * @see #removeHierarchyBoundsListener(HierarchyBoundsListener) * @see #getHierarchyBoundsListeners() * @since 1.3 */ public synchronized void addHierarchyBoundsListener(HierarchyBoundsListener listener) { hierarchyBoundsListener = AWTEventMulticaster.add(hierarchyBoundsListener, listener); if (hierarchyBoundsListener != null) enableEvents(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK); } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see HierarchyEvent * @see #addHierarchyBoundsListener(HierarchyBoundsListener) * @see #getHierarchyBoundsListeners() * @since 1.3 */ public synchronized void removeHierarchyBoundsListener(HierarchyBoundsListener listener) { hierarchyBoundsListener = AWTEventMulticaster.remove(hierarchyBoundsListener, listener); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addHierarchyBoundsListener(HierarchyBoundsListener) * @see #removeHierarchyBoundsListener(HierarchyBoundsListener) * @since 1.4 */ public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() { return (HierarchyBoundsListener[]) AWTEventMulticaster.getListeners(hierarchyBoundsListener, HierarchyBoundsListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see KeyEvent * @see #removeKeyListener(KeyListener) * @see #getKeyListeners() * @since 1.1 */ public synchronized void addKeyListener(KeyListener listener) { keyListener = AWTEventMulticaster.add(keyListener, listener); if (keyListener != null) enableEvents(AWTEvent.KEY_EVENT_MASK); } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see KeyEvent * @see #addKeyListener(KeyListener) * @see #getKeyListeners() * @since 1.1 */ public synchronized void removeKeyListener(KeyListener listener) { keyListener = AWTEventMulticaster.remove(keyListener, listener); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addKeyListener(KeyListener) * @see #removeKeyListener(KeyListener) * @since 1.4 */ public synchronized KeyListener[] getKeyListeners() { return (KeyListener[]) AWTEventMulticaster.getListeners(keyListener, KeyListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see MouseEvent * @see #removeMouseListener(MouseListener) * @see #getMouseListeners() * @since 1.1 */ public synchronized void addMouseListener(MouseListener listener) { mouseListener = AWTEventMulticaster.add(mouseListener, listener); if (mouseListener != null) enableEvents(AWTEvent.MOUSE_EVENT_MASK); // TODO is this still needed ? flags |= IS_MOUSE_AWARE; } /** * Removes the specified listener from the component. This is harmless if * the listener was not previously registered. * * @param listener the listener to remove * @see MouseEvent * @see #addMouseListener(MouseListener) * @see #getMouseListeners() * @since 1.1 */ public synchronized void removeMouseListener(MouseListener listener) { mouseListener = AWTEventMulticaster.remove(mouseListener, listener); // TODO is this still needed? checkMouseAware(); } /** * Returns an array of all specified listeners registered on this component. * * @return an array of listeners * @see #addMouseListener(MouseListener) * @see #removeMouseListener(MouseListener) * @since 1.4 */ public synchronized MouseListener[] getMouseListeners() { return (MouseListener[]) AWTEventMulticaster.getListeners(mouseListener, MouseListener.class); } /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. * * @param listener the new listener to add * @see MouseEvent * @see #removeMouseMotionListener(MouseMotionListener) * @see #getMouseMotionListeners() * @since 1.1 */ public synchronized void addMouseMotionListener(MouseMotionListener listener) { mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener); if (mouseMotionListener != null) enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); // TODO is this still needed ?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -