这里只显示实现了颜色盘的代码,其他完整代码在文件里,需要请下载
JButton jb=new JButton(" 颜色板 " );
jb.setBounds(470,30,90,40);
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Color newcolor=JColorChooser.showDialog(drawpJPanel,"调色板", drawpJPanel.getBackground());
if(newcolor!=null){
frontLabel.setBackground(newcolor);//JFrame类里面只能由内容面板来设定颜色
}});
foot.add(jb);
JButton jb=new JButton(" 颜色板 " );
jb.setBounds(470,30,90,40);
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Color newcolor=JColorChooser.showDialog(drawpJPanel,"调色板", drawpJPanel.getBackground());
if(newcolor!=null){
frontLabel.setBackground(newcolor);//JFrame类里面只能由内容面板来设定颜色
}});
foot.add(jb);