import java.io.*; import java.awt.*; import java.awt.event.*; class DRTest extends Frame{ // Version & Autor private static final String VersionsDatum = "28.9.2004"; private static final String Autor = "Manfred Sommer"; private static String Titel = "Datei Lesen Test"; // Fonts private static final Font FontMono = new Font("Monospaced", Font.PLAIN, 18); private static final Font FontSansSerif = new Font("SansSerif", Font.PLAIN, 14); private static final Font BigItalicSansSerif = new Font("SansSerif", Font.ITALIC, 16); // Haupt - Fenstergrösse private static int XMax = 1000; private static int YMax = 700; // Fenstergrösse für Meldungen private static int XMeld0 = 20; private static int YMeld0 = 60; private static int XMeldW = 900; private static int YMeldH = 600; // Fenster für Meldungen private static TextArea Meldungen = new TextArea(); // Beginn Menü private static MenuBar MainMenuBar = new MenuBar(); private static Menu DateiMenu = new Menu("Datei"); private static MenuItem DateiRead = new MenuItem("Datei lesen..."); private static MenuItem Beenden = new MenuItem("Exit"); private static Menu HelpMenu = new Menu("Hilfe"); private static MenuItem AboutBox = new MenuItem("About"); // End Menü //// Konstruktor. DRTest () { super(Titel); // Fonts für Menüs setFont(FontMono); DateiMenu.setFont(FontSansSerif); DateiRead.setFont(FontSansSerif); Beenden.setFont(FontSansSerif); HelpMenu.setFont(FontSansSerif); AboutBox.setFont(FontSansSerif); // Font für Text Bereich setFont(new Font("Monospaced", Font.PLAIN, 18)); setLayout(null); setMenuBar(MainMenuBar); MainMenuBar.add(DateiMenu); DateiMenu.add(DateiRead); DateiMenu.add(Beenden); MainMenuBar.add(HelpMenu); HelpMenu.add(AboutBox); Meldungen.setBounds(XMeld0,YMeld0,XMeldW,YMeldH); Meldungen.setEditable(false); add(Meldungen); DateiRead.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ doReadFile();} }); Beenden.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ FensterBeenden(); } }); AboutBox.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ showAboutBox(); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { FensterBeenden(); } }); setBackground(Color.lightGray); setSize(XMax, YMax); setVisible(true); } void FensterBeenden() { dispose(); System.exit(0); } // show about box void showAboutBox(){ final Frame f = new Frame("About Box"); final Button Ok = new Button("Ok"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { f.dispose(); } }); Ok.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { f.dispose(); } }); f.setFont (BigItalicSansSerif); f.setLayout (new GridLayout(0, 1)); f.add(new Label(" ", Label.CENTER)); f.add(new Label("Test von Datei Lesen", Label.CENTER)); f.add(new Label("Datum der letzten Änderung: " + VersionsDatum, Label.CENTER)); f.add(new Label("Autor: Manfred Sommer", Label.CENTER)); f.add(new Label(" ", Label.CENTER)); f.add(Ok); f.pack(); f.setVisible(true); } void doReadFile(){ String dn = DD.getDateiName(this); Meldungen.append("Dateiname: " + dn +"\n"); DR.readFile(dn, Meldungen); } public static void main(String args[]) { new DRTest(); } }