怎么用setBackground(Color)没起作用,没颜色变化
import javax.swing.*;
import java.awt.*;
public class Chuangkou {
public static void main(String[] args)
{
JFrame jf=new JFrame("按钮对象的创建");
JButton btn1=new JButton("按钮一");
JButton btn2=new JButton("");
btn2.setText("按钮二");
Container cp=jf.getContentPane();
jf.setForeground(Color.yellow);
jf.setBackground(Color.red);
cp.setLayout(null);
jf.setSize(400,250);
jf.setLocation(400,250);
cp.add(btn1);
cp.add(btn2);
btn1.setBounds(60,20,80,30);
btn2.setBounds(60,60,80,30);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
}
}
import java.awt.*;
public class Chuangkou {
public static void main(String[] args)
{
JFrame jf=new JFrame("按钮对象的创建");
JButton btn1=new JButton("按钮一");
JButton btn2=new JButton("");
btn2.setText("按钮二");
Container cp=jf.getContentPane();
jf.setForeground(Color.yellow);
jf.setBackground(Color.red);
cp.setLayout(null);
jf.setSize(400,250);
jf.setLocation(400,250);
cp.add(btn1);
cp.add(btn2);
btn1.setBounds(60,20,80,30);
btn2.setBounds(60,60,80,30);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
}
}
...全文
相关推荐
java更换窗口背景颜色
利用java代码更换创口背景颜色 class SimpleChangePanel extends JPanel implements ActionListener { private JButton yellowButton; public SimpleChangePanel() { yellowButton = new JButton("Yellow"); add(yellowButton); yellowButton.addActionListener(this); } public void actionPerformed(ActionEvent evt) { Color color = Color.yellow; setBackground(color); repaint(); } }
android-EditText边框颜色
android-EditText边框颜色 ,完整源码,适用初学者
线性seekBar颜色获取渐变某点的颜色
转载自http://blog.csdn.net/u010593680/article/details/50987671,最近要搞颜色选择,找到方法因为没有demo随便弄一下,方便大家学习
Java中颜色设置实例.pdf
Java中颜色设置实例.pdf 学习资料 复习资料 教学资源
Android使用selector修改TextView中字体颜色和背景色的方法
主要介绍了Android使用selector修改TextView中字体颜色和背景色的方法,实例分析了selector方法的相关使用技巧,需要的朋友可以参考下


