Greeting all.
This may not be interesting to anyone else but I like it:
I have several Java apps that I wrote for various reasons. I really find the whole IPK thing a major hassle as these are really just for me. I was content for a while to run my apps from the console (I wrote a bash script to list my classes and give me a choice) but it ocurred to me that it would be good to have a "launcher app" that I could put on the desktop that would read a text file (zlnch.txt) of otherwise stand-alone apps and luanch them. That way, any new app I write, I just copy the classes off to my CF card and edit the text file and I'm done. The apps need to have a argument-less constructor and basically do nothing in "main" but call the constructor.
So, anyway, if anyone is interested:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class jlnch extends Frame {
// class data
static TextField appnm;
static String rs;
static Choice apln=new Choice();
// main method
public static void main(String args[]) throws IOException {
//Initilaize
apln.add("");
BufferedReader iniFile = new BufferedReader(new FileReader("zlnch.txt"));
while ((rs =iniFile.readLine()) != null) {apln.add(rs);}
apln.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e) {
String ct = apln.getSelectedItem();
try {
Class cls = Class.forName(ct);
cls.newInstance();
}
catch (ClassNotFoundException e2) { }
catch (IllegalAccessException e3) { }
catch (InstantiationException e4) { }
}
});
//call constructor
jlnch jl1 = new jlnch();
}
// constructor method
public jlnch() {
setTitle("app launcher");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
ScrollPane sp = new ScrollPane();
Panel p0 = new Panel();
p0.setLayout(new GridLayout(1,0));
p0.add(apln);
//
sp.add(p0);
sp.setSize(200,40);
add("Center", sp);
pack();
show();
}
}