import java.awt.*; import java.awt.event.*; import java.io.*; public class grupp1 extends Frame implements ActionListener{ Panel leht=new Panel(); Panel kakskokku=new Panel(); Panel kokku1=new Panel(); Panel kokku2=new Panel(); Panel lahtrid1=new Panel(); Panel veerga=new Panel(); Panel veergb=new Panel(); Panel lahtrid2=new Panel(); Panel veergc=new Panel(); Panel veergd=new Panel(); Panel allkokku=new Panel(); Panel keskosa=new Panel(); Panel allkokku1=new Panel(); Panel allkokku2=new Panel(); Panel allkokku3=new Panel(); Panel keskmine=new Panel(); Panel nupp1=new Panel(); String[] reisiandmed={ "Reisi alguspunkt", "Reisi algusaeg", "Reisi marsruut", "Reisi lopp-punkt", "Reisi lopu aeg" }; String[] tellijaandmed={ "Tellija(firma)nimi", "Tellija aadress", "Tellija telefon", "Tellija fax", "Tellija E-mail" }; String[] all1={"Osauhing Oma Buss", "Reg.nr. 10493297", "Harjumaa Kuusalu vald", "Kuusalu Kuuse tn. 8", "postiindeks 74601"}; String[] all3={"Tel/fax: 22-772-741", "GSM: 250-34-874", "E-mail omabuss@kuusalu.edu.ee", "" ,""}; String[] all2={"Arvelduskonto", "2210112788985", "Hansapank", "", ""}; Label pealkiria= new Label("Andmed reisi kohta", Label.CENTER); Label pealkirib= new Label("Andmed tellija kohta", Label.CENTER); Label pais= new Label("OU OMA BUSS"); Label tasumine= new Label("Tasumise viis"); Label [] sildid1= new Label[5]; Label [] sildid2= new Label[5]; Label[] all11= new Label[5]; Label[] all22= new Label[5]; Label[] all33= new Label[5]; TextField [] tekstv1= new TextField [5]; TextField [] tekstv2= new TextField [5]; Button nupp=new Button("Salvesta"); Choice valik=new Choice(); public grupp1(){ nupp.addActionListener(this); kakskokku.setLayout(new BorderLayout ()); kokku1.setLayout(new BorderLayout ()); kokku2.setLayout(new BorderLayout ()); lahtrid1.setLayout(new BorderLayout()); veerga=new Panel(); veerga.setLayout(new GridLayout (5,1)); veergb=new Panel(); veergb.setLayout(new GridLayout (5,1)); for(int i=0; i<5;i++){ sildid1 [i]= new Label(reisiandmed[i]); tekstv1 [i]= new TextField(30); veerga .add (sildid1[i]); veergb .add (tekstv1[i]); } lahtrid1.add("West", veerga); lahtrid1.add("Center", veergb); kokku1.add("North",pealkiria); kokku1.add("Center",lahtrid1); lahtrid2.setLayout(new BorderLayout ()); veergc.setLayout(new GridLayout (5,1)); veergd.setLayout(new GridLayout (5,1)); for(int i=0; i<5;i++){ sildid2 [i]= new Label(tellijaandmed[i]); tekstv2 [i]= new TextField(20); veergc.add (sildid2[i]); veergd.add (tekstv2[i]); } lahtrid2.add("West", veergc); lahtrid2.add("Center", veergd); kokku2.setLayout(new BorderLayout()); kokku2.add("North",pealkirib); kokku2.add("Center",lahtrid2); kakskokku.add("North",kokku1); kakskokku.add("Center",kokku2); add(kakskokku); valik.add("Sularahas"); valik.add("Arvega"); add(valik); nupp1.add(nupp); add(nupp1); keskmine.setLayout(new BorderLayout()); keskmine.add("West",tasumine); keskmine.add("Center",valik); add(keskmine); allkokku1.setLayout(new GridLayout(5,1)); for (int i=0; i<5; i++){ all11[i]= new Label(all1 [i]); allkokku1.add(all11[i]); } allkokku2.setLayout(new GridLayout(5,1)); allkokku3.setLayout(new GridLayout(5,1)); for (int i=0; i<5; i++){ all22[i]= new Label(all2 [i]); all33[i]= new Label(all3 [i]); allkokku2.add(all22[i]); allkokku3.add(all33[i]); } allkokku.setLayout(new GridLayout(1,3)); allkokku.add(allkokku1); allkokku.add(allkokku2); allkokku.add(allkokku3); add(allkokku); keskosa.setLayout(new BorderLayout()); keskosa.add("North",keskmine); keskosa.add("Center",nupp1); keskosa.add("South",allkokku); add(keskosa); leht.setLayout(new BorderLayout()); leht.add("North",pais); leht.add("Center",kakskokku); leht.add("South",keskosa); add(leht); } public void actionPerformed(ActionEvent e){ try{ PrintWriter faili=new PrintWriter( new FileWriter("andmed.txt", true) ); faili.println("Reisi alguspunkt: "+tekstv1[0].getText()); faili.println("Reisi algusaeg: "+tekstv1[1].getText()); faili.println("Reisi marsruut: "+tekstv1[2].getText()); faili.println("Reisi lopp-punkt: "+tekstv1[3].getText()); faili.println("Reisi lopu aeg: "+tekstv1[4].getText()); faili.println("Tellija (firma)nimi: "+tekstv2[0].getText()); faili.println("Tellija aadress: "+tekstv2[1].getText()); faili.println("Tellija telefon: "+tekstv2[2].getText()); faili.println("Tellija fax: "+tekstv2[3].getText()); faili.println("Tellija E-mail: "+tekstv2[4].getText()); faili.println("Tasumise viis: "+valik.getSelectedItem()); faili.println(); faili.println(); faili.close(); }catch (IOException ex){ System.out.println(ex); } } public static void main (String argumendid[]){ //new grupp(); Frame f=new grupp1(); f.setSize(600, 500); f.setVisible(true); } }