001 package com.croftsoft.core.lang.classloader;
002
003 import java.awt.*;
004 import java.io.*;
005
006 /*********************************************************************
007 * <P>
008 * @version
009 * 1998-06-03
010 * @author
011 * <a href="https://www.croftsoft.com/">David Wallace Croft</a>
012 *********************************************************************/
013
014 public class DialogClassLoader
015 //////////////////////////////////////////////////////////////////////
016 //////////////////////////////////////////////////////////////////////
017 {
018
019 //////////////////////////////////////////////////////////////////////
020 //////////////////////////////////////////////////////////////////////
021
022 /*********************************************************************
023 * Loads a remote class and launches its main() method.
024 *
025 * @param
026 * Command-line arguments:
027 * <OL>
028 * <LI> The URL name for the codebase.
029 * <LI> The name of the class with the "main(args)" method.
030 * <LI> The name of the local persistent resource cache directory.
031 * <LI> Subsequent arguments to be passed to the invoked main method.
032 * </OL>
033 * Example
034 *********************************************************************/
035 public static void main ( String [ ] args )
036 throws Exception
037 //////////////////////////////////////////////////////////////////////
038 {
039 if ( args.length >= 3 )
040 {
041 CacheClassLoader.main ( args );
042 return;
043 }
044
045 ( new DialogClassLoader ( ) ).start ( );
046 }
047
048 public DialogClassLoader ( )
049 //////////////////////////////////////////////////////////////////////
050 {
051 }
052
053 public void start ( )
054 //////////////////////////////////////////////////////////////////////
055 {
056 System.out.println ( System.getProperty ( "java.class.path" ) );
057
058 // Run the user's classpath searching for "mayhem.class".
059 // When you find it, assume that that is the cache path.
060 // Look for a settings file in that directory.
061 // If there is no settings file in that directory, assume defaults and prompt.
062
063 // System.out.println ( System.getProperty ( "user.home" ) );
064
065 File file0 = new File ( "." );
066 try
067 {
068 System.out.println ( file0.getCanonicalPath ( ) );
069 }
070 catch ( Exception ex ) { }
071
072 Frame frame = new Frame ( "Mystic Mayhem Installation" );
073 FileDialog fileDialog = new FileDialog (
074 frame, "Mystic Mayhem - please choose the installation directory",
075 FileDialog.SAVE );
076 fileDialog.setFile ( "mayhem" );
077 frame.setBounds ( 0, 0, 300, 300 );
078 fileDialog.show ( );
079 frame.show ( );
080 // don't forget to dispose of both
081 File file = new File ( fileDialog.getDirectory ( )
082 + File.separator + fileDialog.getFile ( ) );
083
084 try
085 {
086 System.out.println ( file.getCanonicalPath ( ) );
087 }
088 catch ( Exception ex ) { }
089
090 fileDialog.dispose ( );
091 frame.dispose ( );
092 }
093
094 //////////////////////////////////////////////////////////////////////
095 //////////////////////////////////////////////////////////////////////
096 }