Download
button n.
Skip this Video
Loading SlideShow in 5 Seconds..
Button 元件 PowerPoint Presentation
Download Presentation
Button 元件

Button 元件

187 Views Download Presentation
Download Presentation

Button 元件

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Button元件

  2. Button元件

  3. Button元件

  4. public class ko12_1 extends Applet implements ActionListener { Label lb=new Label("輸入密碼:"); TextField tf1=new TextField(25); Button bn=new Button("結果"); TextField tf2=new TextField(25); public void init() { add(lb); add(tf1); tf1.setEchoChar('*'); add(bn); add(tf2); bn.addActionListener(this); } Button元件

  5. public void actionPerformed(ActionEvent e) { if (e.getSource()==bn) { if (Integer.parseInt(tf1.getText())==123456) tf2.setText("正確!!"); else tf2.setText("錯誤!!"); } } } Button元件

  6. Button元件

  7. Button元件

  8. import java.applet.*; import java.awt.*; import java.awt.event.*; public class ko12_4 extends Applet implements ActionListener { TextField tf1=new TextField(10), tf2=new TextField(10); Label lb1=new Label("****徑度與角度的轉換****"), lb2=new Label("輸入徑度:"), lb3=new Label("輸出角度:"); Button bn=new Button("轉換結果"); Button元件

  9. public void init() { add(lb1); add(lb2); add(tf1); add(lb3); add(tf2); add(bn); bn.addActionListener(this); } Button元件

  10. Button元件 public void actionPerformed(ActionEvent e) { String s; if (e.getSource()==bn) { s=String.valueOf(Math.toDegrees(Double.parseDouble(tf1.getText()))); tf2.setText(s); } } }

  11. Button元件

  12. Button元件

  13. Button元件

  14. Button元件 import java.applet.*; import java.awt.*; import java.awt.event.*; public class ko12_5 extends Applet implements ActionListener { TextField tf1=new TextField(6), tf2=new TextField(6), tf3=new TextField(6), tf4=new TextField(6); Label lb1=new Label("*求最大公因數及最小公倍數*"), lb2=new Label("輸入第一個數值:"), lb3=new Label("輸入第二個數值:"),

  15. lb4=new Label("輸出最大公因數:"), lb5=new Label("輸出最小公倍數:"); Button bn=new Button("輸出結果"); public void init() { add(lb1); add(lb2); add(tf1); add(lb3); add(tf2); add(lb4); add(tf3); add(lb5); add(tf4); add(bn); bn.addActionListener(this); } Button元件

  16. public void actionPerformed(ActionEvent e) { int x,y,z,a,b,gcd,lcm; String s,t; x=Integer.parseInt(tf1.getText()); y=Integer.parseInt(tf2.getText()); a=x; b=y; while(y!=0) { z=x%y; x=y; y=z; } Button元件

  17. gcd=x; lcm=a*b/gcd; if (e.getSource()==bn) { s=String.valueOf(gcd); t=String.valueOf(lcm); tf3.setText(s); tf4.setText(t); } } } Button元件