mae.sss
Class Chooser

java.lang.Object
  extended bymae.sss.Chooser

public class Chooser
extends java.lang.Object

Instance methods simplify class loading from a jar file;
class methods add functionality to SSS, mostly to choose from something


Constructor Summary
Chooser(java.lang.ClassLoader L)
          Makes an instance using the ClassLoader L.
 
Method Summary
 java.lang.Class addJarFile()
          Adds a jar file selected by the user
 java.lang.Class addJarFile(java.io.File f)
          Adds a jar file to the ClassLoader and the dialog
 java.lang.Class chooseClass()
          Returns the class selected by the user in the dialog
static java.io.File file()
          Shows standard file chooser
static java.io.File file(java.lang.String e)
          Shows standard file chooser, showing the files with a given extension
static void fonts()
          Shows a font chooser
static java.awt.Frame[] frames()
          An array of active Frames, including hidden ones
static void gc()
          Invokes System.gc(), showing time and free memory
static java.lang.ClassLoader getLoader(java.lang.Object x)
          Who loaded this Object?
static java.lang.Class loadClass()
          Shows standard file chooser to choose a class file.
static java.lang.Class loadClass(java.net.URL u, java.lang.String name)
          Most general loading method: loads any class anywhere, if its URL is known.
 java.lang.ClassLoader loader()
          Returns the ClassLoader associated with this Chooser
static Chooser makeChooser()
          Chooses a jar file and makes a Chooser with it using a new Loader object;
returns null if a jar file is not chosen
static java.lang.Class systemClass()
          Shows a dialog to choose a java class
(classes that begin with java and javax can be chosen).
static java.lang.Class systemClass(java.lang.String name)
          Chooses system class by name
(searching java classes, extensions, and the class path)
static java.lang.Thread[] threads()
          An array of active Threads
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chooser

public Chooser(java.lang.ClassLoader L)
Makes an instance using the ClassLoader L.

All jar files related to L will be scanned and a dialog will be made.

Method Detail

makeChooser

public static Chooser makeChooser()
                           throws java.net.MalformedURLException
Chooses a jar file and makes a Chooser with it using a new Loader object;
returns null if a jar file is not chosen

Throws:
java.net.MalformedURLException

frames

public static java.awt.Frame[] frames()
An array of active Frames, including hidden ones


threads

public static java.lang.Thread[] threads()
An array of active Threads


gc

public static void gc()
Invokes System.gc(), showing time and free memory


file

public static java.io.File file()
Shows standard file chooser


file

public static java.io.File file(java.lang.String e)
Shows standard file chooser, showing the files with a given extension


systemClass

public static java.lang.Class systemClass()
                                   throws java.lang.ClassNotFoundException
Shows a dialog to choose a java class
(classes that begin with java and javax can be chosen).

Throws:
java.lang.ClassNotFoundException

systemClass

public static java.lang.Class systemClass(java.lang.String name)
                                   throws java.lang.ClassNotFoundException
Chooses system class by name
(searching java classes, extensions, and the class path)

Throws:
java.lang.ClassNotFoundException

getLoader

public static java.lang.ClassLoader getLoader(java.lang.Object x)
Who loaded this Object?


loadClass

public static java.lang.Class loadClass()
                                 throws java.lang.ClassNotFoundException
Shows standard file chooser to choose a class file. Choosing a loaded class will load the new version, if modified since last loading

Throws:
java.lang.ClassNotFoundException

loadClass

public static java.lang.Class loadClass(java.net.URL u,
                                        java.lang.String name)
                                 throws java.lang.ClassNotFoundException
Most general loading method: loads any class anywhere, if its URL is known.

Use of loadClass(URL, String)

 1. choose jar File that contains your class
   f = Chooser.file("jar");

 2. get URL of that File object
   u = f.toURL();

 3. press ESC and load your class
   Chooser.loadClass(u, "Hello");
   class Hello
 

How to load a remote class

 1. get URL class (click on java.net and then on URL)
   Chooser.systemClass();
   class java.net.URL

 2. enter URL of a remote Applet (the slash at the end is crucial)
   u2 = new URL("http://java.sun.com/applets/jdk/1.4/demo/applets/ArcTest/");

 3. press ESC and load your class (MAY TAKE SOME TIME)
   Chooser.loadClass(u2, "ArcTest");
   class ArcTest

 4. make an instance
   arc = new ArcTest();

 5. press ESC and show the Applet (you need to resize the Frame)
   Menu.toFrame(arc);
 

Throws:
java.lang.ClassNotFoundException

fonts

public static void fonts()
Shows a font chooser


loader

public java.lang.ClassLoader loader()
Returns the ClassLoader associated with this Chooser


chooseClass

public java.lang.Class chooseClass()
                            throws java.lang.ClassNotFoundException
Returns the class selected by the user in the dialog

Throws:
java.lang.ClassNotFoundException

addJarFile

public java.lang.Class addJarFile()
Adds a jar file selected by the user


addJarFile

public java.lang.Class addJarFile(java.io.File f)
Adds a jar file to the ClassLoader and the dialog