📄 chapter2.java
字号:
/*@author 邱宇峰 ,software project031,
*2004,10,8
*/
import java.awt.*;
import java.awt.event.*;
public class chapter2 extends Frame implements ActionListener,ItemListener,MouseListener{
static chapter2 frm=new chapter2();
static Graphics g;
static Panel pl;
static Button b;
static int count=0;
static int location[][]=new int[30][2];
static Choice ch=new Choice();
public static void main(String[] args){
pl=new Panel();
pl.setLayout(new FlowLayout());
b=new Button("clean");
b.addActionListener(frm);
ch.add("NewTon (Color is yellow)");
ch.add("Lagrange (Color is red)");
ch.add("ThreeSamples (Color is black)");
ch.addItemListener(frm);
pl.add(b);
frm.setTitle("第二章");
frm.add(ch,"North");
frm.add(pl,"South");
frm.setSize(500,500);
frm.setVisible(true);
frm.addMouseListener(frm);
frm.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}
});
g=frm.getGraphics();
}
public void actionPerformed(ActionEvent e){
Graphics g=getGraphics();
repaint();
location=new int[30][2];
count=0;
}
public void mouseClicked(MouseEvent e){
int x=e.getX();
int y=e.getY();
location[count][0]=x;location[count][1]=y;
g.drawString("。",x,y);
count++;
}
public void mouseEntered(MouseEvent e){ }
public void mousePressed(MouseEvent e){ }
public void mouseExited(MouseEvent e){ }
public void mouseReleased(MouseEvent e){}
public void itemStateChanged(ItemEvent e){
int index=ch.getSelectedIndex();
call1 cal=new call1();
cal.act(index,location,count,g);
}
}
class call1{
void act(int choice,int location[][],int count,Graphics g){
switch(choice){
case 0:newton1 n=new newton1();n.action(location,count,g);break;
case 1:largeLangre1 l=new largeLangre1(location,count,g); break;
case 2:threeSamples1 t=new threeSamples1(location,count,g);break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -