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