📄 color.java
字号:
/*
* color.java
*
* Created on 2007年6月23日, 下午2:53
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package huaban;
import java.awt.Button;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
/**
*
* @author Administrator
*/
public class color extends JPanel implements ActionListener{
JCheckBox[] box = new JCheckBox[12];
JCheckBox box1;
JPanel[] panel = new JPanel[7];
JPanel[] panel1 = new JPanel[6];
Color state;
public color() {
state = Color.BLACK;
box[0] = new JCheckBox(new ImageIcon("1.1.GIF"),true);
box[1] = new JCheckBox(new ImageIcon("1.2.GIF"),true);
box[2] = new JCheckBox(new ImageIcon("1.3.GIF"),true);
box[3] = new JCheckBox(new ImageIcon("1.4.GIF"));
box[4] = new JCheckBox(new ImageIcon("1.5.GIF"));
box[5] = new JCheckBox(new ImageIcon("1.6.GIF"));
box[6] = new JCheckBox(new ImageIcon("1.7.GIF"));
box[7] = new JCheckBox(new ImageIcon("1.8.GIF"));
box[8] = new JCheckBox(new ImageIcon("1.9.GIF"));
box[9] = new JCheckBox(new ImageIcon("1.10.GIF"));
box[10] = new JCheckBox(new ImageIcon("1.11.GIF"));
box[11] = new JCheckBox(new ImageIcon("1.12.GIF"));
box1 = new JCheckBox(new ImageIcon("1.1.GIF"));
JToolBar bar = new JToolBar();
bar.setLayout(new GridLayout(1,7));
for(int i = 0; i < 3; i++){
panel[i] = new JPanel();
}
bar.add(box1);
for(int i = 0; i < 6; i++ ){
panel1[i] = new JPanel();
panel1[i].setLayout(new GridLayout(2,1));
panel1[i].add(box[2*i]);
panel1[i].add(box[2*i + 1]);
bar.add(panel1[i]);
}
for(int i = 0; i < 12; i++){
box[i].addActionListener(this);
}
panel[0].add(bar);
this.setLayout(new GridLayout(1,3));
for(int i = 0; i < 3; i++){
this.add(panel[i]);
}
}
public Color getstate(){
return state;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == box[0]){
state = Color.BLACK;
box1.setIcon(box[0].getIcon());
}
if(e.getSource() == box[1]){
state = Color.WHITE;
box1.setIcon(box[1].getIcon());
}
if(e.getSource() == box[2]){
state = Color.BLUE;
box1.setIcon(box[2].getIcon());
}
if(e.getSource() == box[3]){
state = Color.YELLOW;
box1.setIcon(box[3].getIcon());
}
if(e.getSource() == box[4]){
state = Color.GREEN;
box1.setIcon(box[4].getIcon());
}
if(e.getSource() == box[5]){
state = Color.CYAN;
box1.setIcon(box[5].getIcon());
}
if(e.getSource() == box[6]){
state = Color.MAGENTA;
box1.setIcon(box[6].getIcon());
}
if(e.getSource() == box[7]){
state = Color.PINK;
box1.setIcon(box[7].getIcon());
}
if(e.getSource() == box[8]){
state = Color.RED;
box1.setIcon(box[8].getIcon());
}
if(e.getSource() == box[9]){
state = Color.ORANGE;
box1.setIcon(box[9].getIcon());
}
if(e.getSource() == box[10]){
state = Color.DARK_GRAY;
box1.setIcon(box[10].getIcon());
}
if(e.getSource() == box[11]){
state = Color.LIGHT_GRAY;
box1.setIcon(box[11].getIcon());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -