I have implemented a standalone java application which uses the swing framework for GUI.As part of the GUI there is a JTextArea which appears after a button is clicked on and some text is appended at the jtextarea after a job is being processed in the background.I am using the SwingWorker library, as i dont't want my jtextarea to freeze the app and it works perfectly.So the job code lies inside the overriden doInBackground.
The problem that i am facing is when i launch this GUI application as part of an Eclipse plugin.I have build a jar with my swing app and i've added an extension to the Eclipse workbench.In the beginning the app launched properly but when the application flow goes to the point when the swingworker is to be invoked, this specific jtextarea is freezing and nothing happened.It seems that the code inside the doInBackground() function of my Swingworker is not invoked. I am launching the app inside the eclipse pugin code as below:
SwingUtilities.invokeLater(new Runnable() {public void run() {
new MainFrame.setVisible(true);
}
});
where MAinFrame is a JFrame class of the java program. Do you know why is this happening?
It is not easy to mix SWT and AWT/Swing UI in the same process. They require different event loops. Your code is freezing because Awt/Swing event loop is not running in the Eclipse process. You can either re-write your UI in SWT or research SWT-AWT bridge. The bridge "works", but has numerous glitches. It is really only appropriate for situation where there is an enormous amount of AWT/Swing and a temporary solution is necessary while the UI is ported to SWT.