?? 例7-23.java
字號:
//example 7-23
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class tt extends Applet implements ItemListener,ActionListener
{
List colorList;
String colorNames[]={"Red","Green","Blue","Yellow"};
Color colors[]={Color.red,Color.green,Color.blue,Color.yellow};
Checkbox red,green,blue,yellow;
int k;
public void init()
{
colorList=new List(3,false);
colorList.addActionListener(this);
colorList.addItemListener(this);
for(int i=0;i<colorNames.length;i++)
colorList.add(colorNames[i]);
add(colorList);
}
public void actionPerformed(ActionEvent e)
{
}
public void itemStateChanged(ItemEvent e)
{
showStatus(colorList.getSelectedItem()+";index "+colorList.getSelectedIndex());
k=colorList.getSelectedIndex();
repaint();
}
public void paint(Graphics g)
{
g.setColor(colors[k]);
g.fillRect(10,40,20,20);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -