import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class Tekst extends Frame { private String a; static String kuup, kell, kella; private TextArea ta; private TextField from, to; private String fnimi, rida, ridak; public Tekst() { setTitle("Teksti redaktor"); MenuBar mbar = new MenuBar(); Menu m = new Menu("File"); m.add(new MenuItem("New")); m.add(new MenuItem("Open")); m.add(new MenuItem("Save")); m.addSeparator(); m.add(new MenuItem("Exit")); mbar.add(m); m = new Menu("Edit"); m.add(new MenuItem("Replace")); m.addSeparator(); m.add(new MenuItem("Date")); m.add(new MenuItem("Time")); mbar.add(m); m = new Menu("Help"); m.add(new MenuItem("Topics")); m.addSeparator(); m.add(new MenuItem("About...")); mbar.add(m); setMenuBar(mbar); ta = new TextArea(15,40); add("North",ta); } public boolean action(Event evt, Object arg) { if (evt.target instanceof MenuItem) if(arg.equals("New")) { ta.setText(""); } else if(arg.equals("Open")) { Open ab1 = new Open(this); ab1.show(); } else if(arg.equals("Save")) { Save ab2 = new Save(this); ab2.show(); } else if(arg.equals("Replace")) { Replace ab7 = new Replace(this); ab7.show(); } else if(arg.equals("Date")) { Calendar kalender=new GregorianCalendar(); kuup = kalender.get(Calendar.DAY_OF_MONTH)+"-"+(1+(kalender.get(Calendar.MONTH)))+ "-"+kalender.get(Calendar.YEAR); String vana = ta.getText(); String uus = vana + " " + kuup; ta.setText(uus); } else if(arg.equals("Time")) { Calendar kalender=new GregorianCalendar(); if (kalender.get(Calendar.MINUTE)<10) kella = "0"; else kella = ""; kell = kalender.get(Calendar.HOUR_OF_DAY)+":"+kella+kalender.get(Calendar.MINUTE)+ ":"+kalender.get(Calendar.SECOND); String vana = ta.getText(); String uus = vana + " " + kell; ta.setText(uus); } else if(arg.equals("Topics")) { } else if(arg.equals("About...")) { About ab9 = new About(this); ab9.show(); } else if(arg.equals("Exit")) { System.exit(0); } else return super.action(evt, arg); return true; } public static void main(String arg[]) { Frame f = new Tekst(); f.setLocation(200,200); f.resize(400, 300); f.show(); } public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_DESTROY && evt.target == this) System.exit(0); return super.handleEvent(evt); } class Open extends Dialog { String fail1 = ""; TextField failnimi = new TextField("",10); public Open(Frame parent) { super(parent, "Open", true); File kataloog = new File("."); String failid[]=kataloog.list(); for(int i=0; i= 0 && f.length() > 0) ta.replaceText(to.getText(), n, n + f.length()); } else return super.action(evt, arg); dispose(); return true; } } class About extends Dialog { public About(Frame parent) { super(parent, "About...", true); Panel p = new Panel(); p.setLayout(new GridLayout(5,1)); p.add(new Label("Programeerisid:")); p.add(new Label("Laivi Käsper")); p.add(new Label("Kirsti Kislenko")); p.add(new Label("Maarit Kukk")); p.add(new Label("Janno Rütter")); add("North",p); add("South", new Button(" Ok ")); resize(70, 170); setLocation(250, 300); } public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_DESTROY) dispose(); return super.handleEvent(evt); } public boolean action(Event evt, Object arg) { if (arg.equals(" Ok ")) dispose(); return true; } } }