📄 chapter3.java
字号:
/*@author 邱宇峰 ,software project031,
*2004,10,8
*/
import java.awt.*;
import java.awt.event.*;
public class chapter3 extends Frame implements ActionListener,ItemListener{
static chapter3 frm=new chapter3();
static Graphics g;
static Panel pl;
static Button b;
static Label l;
static TextField tf;
static Choice ch=new Choice();
public static void main(String[] args){
ch.add("GoldenSearch calculate(cosX)function's max value");
ch.add("HalfSearch calculate(X=2sinX)function's all value");
ch.add("MaxSpeedSearch calculate(/(x*x+y*y+2))function's max value");
ch.addItemListener(frm);
frm.setTitle("第3章");
l=new Label("current height is");
tf=new TextField(15);
pl=new Panel();
pl.setLayout(new FlowLayout());
b=new Button("clean");
b.addActionListener(frm);
pl.setLayout(new FlowLayout());
pl.add(b); pl.add(l); pl.add(tf);
frm.add(ch,"North");
frm.add(pl,"South");
frm.setSize(700,700);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}
});
g=frm.getGraphics();
}
public void actionPerformed(ActionEvent e){
Graphics g=getGraphics();
repaint();
}
public void itemStateChanged(ItemEvent e){
int index=ch.getSelectedIndex();
call3 cal=new call3();
cal.act(index,g,tf);
}
}
class call3{
void act(int choice,Graphics g,TextField tf){
switch(choice){
case 0:goldenSearch1 gS=new goldenSearch1(); gS.search(g);break;
case 1:halfSearch1 hS=new halfSearch1(); hS.search(g); break;
case 2:maxSpeedAscending1 mSA=new maxSpeedAscending1();mSA.ascending(g,tf);break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -