home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-10 | 2.5 KB | 115 lines |
- // VersionPanelTest.java
- //
- // Created 09/25/96
- //
- // (C)Copyright 1996 Microsoft Corporation, All rights reserved.
- //
-
- import java.io.*;
- import java.awt.*;
- import com.ms.util.*;
-
-
- public
- class VersionPanelTest extends TestFrame
- {
- MenuItem openitem;
- VersionPanel verpanel;
- static String BASE_TITLE = "VersionPanelTest";
-
-
- // Updates the window with information about a new file, if available.
-
- public void newfile (File file)
- {
- if (file == null)
- {
- verpanel.clearInfo();
- return;
- }
-
- try
- {
- FileVersionInformation version;
-
- version = new FileVersionInformation(file);
- verpanel.changeInfo(version);
- }
- catch (IOException e)
- {
- // Information could not be obtained.
-
- verpanel.clearInfo();
- }
- catch (SecurityException e)
- {
- // If an applet, the exception was probably already logged.
-
- if (!isapplet)
- {
- System.err.println("unexpected FileVersionInformation error: "+e);
- e.printStackTrace();
- }
-
- verpanel.clearInfo();
- }
-
- setTitle(BASE_TITLE + " - " + file.getAbsolutePath());
- verpanel.repaint();
- }
-
-
- // from TestFrame - add custom File menu items
-
- protected void addFileMenuItems (Menu filemenu)
- {
- openitem = new MenuItem("Open...");
- filemenu.add(openitem);
- }
-
-
- public VersionPanelTest (File file)
- {
- super(BASE_TITLE);
-
- verpanel = new VersionPanel();
- add("Center",verpanel);
-
- pack();
-
- newfile(file);
-
- show();
- }
-
-
- public boolean handleEvent (Event e)
- {
- if (e.target == openitem)
- {
- FileDialog dlg = new FileDialog(this, "Get File Version");
- dlg.show();
- if (dlg.getFile() != null)
- {
- String filename = dlg.getDirectory()+dlg.getFile();
- newfile(new File(filename));
- }
- }
-
- return super.handleEvent(e);
- }
-
-
- public static void main (String[] args)
- {
- if (args.length > 1)
- {
- System.err.println("usage: VersionPanelText [file]");
- System.exit(1);
- }
-
- new VersionPanelTest(args.length > 0 ? new File(args[0]) : null);
- }
- }
-
-