当前位置: 首页>>代码示例>>Java>>正文


Java ComponentPeer.setBackground方法代码示例

本文整理汇总了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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Component.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Component.java


注:本文中的java.awt.peer.ComponentPeer.setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。