import java.applet.Applet; import java.awt.*; import java.io.*; import java.awt.Frame; import java.awt.event.*; import java.util.*; public class Hinnetetabel extends Applet { Choice valik=new Choice(); public Hinnetetabel(){ init(); valik.addItem("sinine"); valik.add("punane"); valik.addItem("kollane"); valik.addItem("roheline"); valik.addItem("hall"); valik.addItem("roosa"); valik.addItem("oranz"); valik.addItem("must"); valik.addItem("cyan"); valik.addItem("magenta"); add(valik); } public void init(){ ValikuKuular kuular=new ValikuKuular(valik); valik.addItemListener(kuular); } public static void main(String argumendid[])throws Exception{ TextField t=new TextField(""); Applet a=new Hinnetetabel(); a.init(); Frame f=new Frame("Vali tausta värv"); f.setSize(200, 200); f.setVisible(true); f.addWindowListener(new Hinnetetabelkuular()); f.add(a); f.setVisible(true); } } class ValikuKuular implements ItemListener{ Choice valik; public ValikuKuular(Choice c1){ valik=c1; } public void itemStateChanged(ItemEvent e){ try{ PrintWriter valja=new PrintWriter(new FileWriter("blankett.html")); System.out.println("OK käes!"); valja.println("Tere!"); String varv="black"; if(valik.getSelectedItem().equals("sinine")){ varv="blue"; } if(valik.getSelectedItem().equals("kollane")){ varv="yellow"; } if(valik.getSelectedItem().equals("punane")){ varv="red"; } if(valik.getSelectedItem().equals("roheline")){ varv="green"; } if(valik.getSelectedItem().equals("hall")){ varv="gray"; } if(valik.getSelectedItem().equals("roosa")){ varv="pink"; } if(valik.getSelectedItem().equals("oranz")){ varv="orange"; } if(valik.getSelectedItem().equals("cyan")){ varv="cyan"; } if(valik.getSelectedItem().equals("magenta")){ varv="magenta"; } valja.println("

Siin on õpilaste viimase veerandi hinded



"); valja.println(""); BufferedReader sisse=new BufferedReader( new FileReader("hinded.txt") ); String rida=sisse.readLine(); while(rida!=null){ System.out.println(rida); StringTokenizer stk=new StringTokenizer(rida, " "); valja.println(""); rida=sisse.readLine(); } sisse.close(); valja.println("
***matemfüüsikakeemia
"+stk.nextToken()+""+stk.nextToken()+""+stk.nextToken()+""+stk.nextToken()+"
"); valja.close(); }catch(Exception error){error.getMessage() ;} } public void mouseMoved(MouseEvent e){} } class Hinnetetabelkuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.out.println("Programmi ots"); System.exit(0); } }