?? aa.java
字號:
import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;
public class aa extends Applet implements ActionListener ,Runnable{
Label prompt;
TextField tf;
Button btn;
int limnum;
Thread thread1;
public void init()
{prompt =new Label("請輸入上限:");
tf=new TextField(10);
btn=new Button("開始");
add(prompt);
add(tf);
add(btn);
btn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn)
limnum=Integer.parseInt(tf.getText());
repaint();
}
public void start()
{thread1=new Thread(this,"Thread");
thread1.start();}
public int zhishu(int number){
for (int i=2;i<number;i++)
if(number%i==0) return 0;
return 1;
}
public void run(){}
public void paint(Graphics g){
for(int i=1;i<=limnum;i++)
{if(zhishu(i)==1) g.setColor(Color.green);
else g.setColor(Color.red);
g.drawString(" /n ",0,0);
g.drawString(""+i,10+i%4*120,20+i/4*15);
}}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -