📄 colorb.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class color extends Applet implements ItemListener
{
CheckboxGroup colors=new CheckboxGroup();
Checkbox red,yellow,green,blue;
public void init()
{
red= new Checkbox("red",colors,false);
yellow=new Checkbox("yellow",colors,false);
green= new Checkbox("green",colors,false);
blue= new Checkbox("blue",colors,false);
Label i1=new Label("the 4 radio buttons will change the screen colors");
Label i2=new Label(" notice that you can only select one radio button");
Label i3=new Label("select a radio button triggers an event");
Label i4=new Label("that we use to change the screen color");
add(i1);
add(red);
add(yellow);
add(green);
add(blue);
add(i2);
add(i3);
add(i4);
red.addItemListener(this);
yellow.addItemListener(this);
green.addItemListener(this);
blue.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
Object src=e.getSource();
if(src==red)setBackground(Color.red);
if(src==yellow)setBackground(Color.yellow);
if(src==green)setBackground(Color.green);
if(src==blue)setBackground(Color.blue);
}
}
//<applet code="color.class" height="300"width="300"></applet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -