|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmae.sss.Chooser
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 |
public Chooser(java.lang.ClassLoader L)
All jar files related to L will be scanned and a dialog will be made.
| Method Detail |
public static Chooser makeChooser()
throws java.net.MalformedURLException
java.net.MalformedURLExceptionpublic static java.awt.Frame[] frames()
public static java.lang.Thread[] threads()
public static void gc()
public static java.io.File file()
public static java.io.File file(java.lang.String e)
public static java.lang.Class systemClass()
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Class systemClass(java.lang.String name)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic static java.lang.ClassLoader getLoader(java.lang.Object x)
public static java.lang.Class loadClass()
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Class loadClass(java.net.URL u,
java.lang.String name)
throws java.lang.ClassNotFoundException
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);
java.lang.ClassNotFoundExceptionpublic static void fonts()
public java.lang.ClassLoader loader()
public java.lang.Class chooseClass()
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic java.lang.Class addJarFile()
public java.lang.Class addJarFile(java.io.File f)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||