📄 jcomponent.java
字号:
public PropertyChangeListener[] getPropertyChangeListeners(String property) { return changeSupport == null ? new PropertyChangeListener[0] : changeSupport.getPropertyChangeListeners(property); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>boolean</code> values. */ public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>byte</code> values. */ public void firePropertyChange(String propertyName, byte oldValue, byte newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Byte(oldValue), new Byte(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>char</code> values. */ public void firePropertyChange(String propertyName, char oldValue, char newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Character(oldValue), new Character(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>double</code> values. */ public void firePropertyChange(String propertyName, double oldValue, double newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Double(oldValue), new Double(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>float</code> values. */ public void firePropertyChange(String propertyName, float oldValue, float newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Float(oldValue), new Float(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>int</code> values. */ public void firePropertyChange(String propertyName, int oldValue, int newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Integer(oldValue), new Integer(newValue)); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>long</code> values. */ public void firePropertyChange(String propertyName, long oldValue, long newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Long(oldValue), new Long(newValue)); } /** * Call {@link PropertyChangeListener#propertyChange} on all listeners * registered to listen to a given property. Any method which changes * the specified property of this component should call this method. * * @param propertyName The property which changed * @param oldValue The old value of the property * @param newValue The new value of the property * * @see #changeSupport * @see #addPropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) */ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * A variant of {@link #firePropertyChange(String,Object,Object)} * for properties with <code>short</code> values. */ public void firePropertyChange(String propertyName, short oldValue, short newValue) { if (changeSupport != null) changeSupport.firePropertyChange(propertyName, new Short(oldValue), new Short(newValue)); } /** * Call {@link VetoableChangeListener#vetoableChange} on all listeners * registered to listen to a given property. Any method which changes * the specified property of this component should call this method. * * @param propertyName The property which changed * @param oldValue The old value of the property * @param newValue The new value of the property * * @throws PropertyVetoException if the change was vetoed by a listener * * @see #addVetoableChangeListener * @see #removeVetoableChangeListener */ protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { VetoableChangeListener[] listeners = getVetoableChangeListeners(); PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, oldValue, newValue); for (int i = 0; i < listeners.length; i++) listeners[i].vetoableChange(evt); } /** * Get the value of the accessibleContext property for this component. * * @return the current value of the property */ public AccessibleContext getAccessibleContext() { return null; } /** * Get the value of the {@link #alignmentX} property. * * @return The current value of the property. * * @see #setAlignmentX * @see #alignmentY */ public float getAlignmentX() { float ret = alignmentX; if (alignmentX < 0) // alignment has not been set explicitly. ret = super.getAlignmentX(); return ret; } /** * Get the value of the {@link #alignmentY} property. * * @return The current value of the property. * * @see #setAlignmentY * @see #alignmentX */ public float getAlignmentY() { float ret = alignmentY; if (alignmentY < 0) // alignment has not been set explicitly. ret = super.getAlignmentY(); return ret; } /** * Get the current value of the {@link #autoscrolls} property. * * @return The current value of the property */ public boolean getAutoscrolls() { return autoscrolls; } /** * Set the value of the {@link #border} property. * * @param newBorder The new value of the property * * @see #getBorder */ public void setBorder(Border newBorder) { Border oldBorder = getBorder(); if (oldBorder == newBorder) return; border = newBorder; firePropertyChange("border", oldBorder, newBorder); repaint(); } /** * Get the value of the {@link #border} property. * * @return The property's current value * * @see #setBorder */ public Border getBorder() { return border; } /** * Get the component's current bounding box. If a rectangle is provided, * use this as the return value (adjusting its fields in place); * otherwise (of <code>null</code> is provided) return a new {@link * Rectangle}. * * @param rv Optional return value to use * * @return A rectangle bounding the component */ public Rectangle getBounds(Rectangle rv) { if (rv == null) return new Rectangle(getX(), getY(), getWidth(), getHeight()); else { rv.setBounds(getX(), getY(), getWidth(), getHeight()); return rv; } } /** * Prepares a graphics context for painting this object. If {@link * #debugGraphicsOptions} is not equal to {@link * DebugGraphics#NONE_OPTION}, produce a new {@link DebugGraphics} object * wrapping the parameter. Otherwise configure the parameter with this * component's foreground color and font. * * @param g The graphics context to wrap or configure * * @return A graphics context to paint this object with * * @see #debugGraphicsOptions * @see #paint */ protected Graphics getComponentGraphics(Graphics g) { Graphics g2 = g; int options = getDebugGraphicsOptions(); if (options != DebugGraphics.NONE_OPTION) { if (!(g2 instanceof DebugGraphics)) g2 = new DebugGraphics(g); DebugGraphics dg = (DebugGraphics) g2; dg.setDebugOptions(dg.getDebugOptions() | options); } g2.setFont(this.getFont()); g2.setColor(this.getForeground()); return g2; } /** * Get the value of the {@link #debugGraphicsOptions} property. * * @return The current value of the property. * * @see #setDebugGraphicsOptions * @see #debugGraphicsOptions */ public int getDebugGraphicsOptions() { String option = System.getProperty("gnu.javax.swing.DebugGraphics"); int options = debugGraphicsOptions; if (option != null && option.length() != 0) { if (options < 0) options = 0; if (option.equals("LOG")) options |= DebugGraphics.LOG_OPTION; else if (option.equals("FLASH")) options |= DebugGraphics.FLASH_OPTION; } return options; } /** * Get the component's insets, which are calculated from * the {@link #border} property. If the border is <code>null</code>, * calls {@link Container#getInsets}. * * @return The component's current insets */ public Insets getInsets() { if (border == null) return super.getInsets(); return getBorder().getBorderInsets(this); } /** * Get the component's insets, which are calculated from the {@link * #border} property. If the border is <code>null</code>, calls {@link * Container#getInsets}. The passed-in {@link Insets} value will be * used as the return value, if possible. * * @param insets Return value object to reuse, if possible * * @return The component's current insets */ public Insets getInsets(Insets insets) { Insets t = getInsets(); if (insets == null) return t; insets.left = t.left; insets.right = t.right; insets.top = t.top; insets.bottom = t.bottom; return insets; } /** * Get the component's location. The passed-in {@link Point} value * will be used as the return value, if possible. * * @param rv Return value object to reuse, if possible * * @return The component's current location */ public Point getLocation(Point rv) { if (rv == null) return new Point(getX(), getY()); rv.setLocation(getX(), getY()); return rv; } /** * Get the component's maximum size. If the {@link #maximumSize} property * has been explicitly set, it is returned. If the {@link #maximumSize} * property has not been set but the {@link #ui} property has been, the * result of {@link ComponentUI#getMaximumSize} is returned. If neither * property has been set, the result of {@link Container#getMaximumSize} * is returned. * * @return The maximum size of the component * * @see #maximumSize * @see #setMaximumSize */ public Dimension getMaximumSize() { if (maximumSize != null) return maximumSize; if (ui != null) { Dimension s = ui.getMaximumSize(this); if (s != null) return s; } Dimension p = super.getMaximumSize(); return p; } /** * Get the component's minimum size. If the {@link #minimumSize} property * has been explicitly set, it is returned. If the {@link #minimumSize} * property has not been set but the {@link #ui} property has been, the * result of {@link ComponentUI#getMinimumSize} is returned. If neither * property has been set, the result of {@link Container#getMinimumSize} * is returned. * * @return The minimum size of the component * * @see #minimumSize * @see #setMinimumSize */ public Dimension getMinimumSize() { if (minimumSize != null) return minimumSize; if (ui != null) { Dimension s = ui.getMinimumSize(this); if (s != null) return s; } Dimension p = super.getMinimumSize(); return p; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -