0

Hi there and thanks for having a look at my question. I'm facing the following problem when developing swing applications in Eclipse: When I try to start a simple swing JFrame application (for example generated by a gui builder like window builder or from small examples out of my programming handbook) the program will run without any error but the JFrame won't by visible. Of course these examples make the JFrame visible at the end with

Framename.setVisible(true).

I think the problem is somewhere located in Eclipse because when I generate a runnable jar of this application in Eclipse and run it outside of Eclipse the JFrame will show up as expected. This behavior occurs with all examples I have tested yet. Do you have a tip for me how to solve this problem? Thanks in advance Richard.

--

Edit: I solved my problem by myself but I don't understand why this works: It seems that swing applications don't work, when they are inside a project which has referenced SWT/JFace libraries (1). As soon as I remove those references, or move the class to another project, the class is back working. Is there any good reason for this behavior?

the mentioned libs

3
  • Are you sure the frame isn't showing up behind the Eclipse IDE? When you run the application, do you show a Java process (on Window's a button on the bottom bar)? Do you have an example of the setup of a frame with the class that has the main that Eclipse is running?
    – Jere
    Commented Jul 13, 2014 at 12:57
  • Yes, I double checked that there is no window behind the IDE (I'm developing on a MBP with OS X 10.9.4). The process is still running, but no window is shown. I now isolated the problemtic jar lib: When I remove the library org.eclipse.swt.cocoa.macosx.x86_64.jar the JFrame will be shown! But why can this lib be problematic in this situation? JFrame is from swing, not from SWT.
    – Richard
    Commented Jul 13, 2014 at 13:09
  • Questions of implementation and debugging belong on Stack Overflow (there are already votes to migrate in place, please do not repost the question). Please read the help center to get a better idea of what questions are appropriate for P.SE and how it differs from Stack Overflow. A rough approximation of the guidelines is that P.SE is for when you are having with a design issue in front of a whiteboard while SO is for when you are in front of an IDE.
    – user289086
    Commented Jul 13, 2014 at 14:04

1 Answer 1

1

If you extended MyClassName extends JFrame you need to use setVisible(true)
Also you can use it when application ready to start, this behaviour is more acceptable:

EventQueue.invokeLater(new Runnable(){
public void run(){
new MyClassName().setVisible(true);
}
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.