本文整理汇总了Java中java.awt.peer.ComponentPeer.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentPeer.setForeground方法的具体用法?Java ComponentPeer.setForeground怎么用?Java ComponentPeer.setForeground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.peer.ComponentPeer
的用法示例。
在下文中一共展示了ComponentPeer.setForeground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setForeground
import java.awt.peer.ComponentPeer; //导入方法依赖的package包/类
/**
* Sets the foreground color of this component.
* @param c the color to become this component's
* foreground color; if this parameter is <code>null</code>
* then this component will inherit
* the foreground color of its parent
* @see #getForeground
* @since JDK1.0
*/
public void setForeground(Color c) {
Color oldColor = foreground;
ComponentPeer peer = this.peer;
foreground = c;
if (peer != null) {
c = getForeground();
if (c != null) {
peer.setForeground(c);
}
}
// This is a bound property, so report the change to
// any registered listeners. (Cheap if there are none.)
firePropertyChange("foreground", oldColor, c);
}
示例2: setForeground
import java.awt.peer.ComponentPeer; //导入方法依赖的package包/类
/**
* Sets the foreground color of this component.
* @param c the color to become this component's
* foreground color; if this parameter is {@code null}
* then this component will inherit
* the foreground color of its parent
* @see #getForeground
* @since 1.0
*/
public void setForeground(Color c) {
Color oldColor = foreground;
ComponentPeer peer = this.peer;
foreground = c;
if (peer != null) {
c = getForeground();
if (c != null) {
peer.setForeground(c);
}
}
// This is a bound property, so report the change to
// any registered listeners. (Cheap if there are none.)
firePropertyChange("foreground", oldColor, c);
}