Reputation: 4150
I have two java Swing applications and I need to be able to execute the first one from the second. I have compiled the first to a jar and placed it in the classpath of the second. I am calling the main class of the first jar from the application but all I see is a blank frame. The Main of my first Jar looks like this:
import java.awt.EventQueue;
import java.awt.Frame;
import javax.swing.JDialog;
public class AskulLibrary extends Frame implements Runnable{
final Frame frame;
public AskulLibrary(Frame frame) {
this.frame = frame;
}
public void run() {
frame.show();
}
public static void main(String[] args) {
JDialog.setDefaultLookAndFeelDecorated(true);
// Throw a nice little title page up on the screen first
new Splash().showSplash(3000);
EventQueue.invokeLater(new AskulLibrary(new JLibrary()));
}
}
I'm calling this main class from the second application like this:
import com.AskulLibrary;
import java.awt.Frame;
public class MainFrame extends JFrame{
AskulLibrary lib;
Frame frame;
public MainFrame(){
frame = new new Frame();
lib = new AskulLibrary (frame);
lib.run();
}
}
I'm doing something wrong somewhere because instead of initializing the first Jar I am getting an empty Frame. I do not want to run the jar like this although this is running the first program successfully:
Runtime.getRuntime().exec("java -jar lib/Myfirstjar.jar");
Upvotes: 1
Views: 392
Reputation: 109815
why not to use implemented methods in official API, How to Create a Splash Screen
(before Splash Screen
was implemented in official APIs) use JWindow
/JDialog
but without using Runnable#Thread
, use the quite strict logics described about Event Dispatch Thread
in InitialThread instead, for both Top-Level Containers
see my question about reverse order, similair, but with interactive logics,
Upvotes: 2