views:

421

answers:

5

Why are my Swing applications not closing when using Netbeans 6.5 on Ubuntu 8.10 with Sun JDK 6. Even the Netbeans tutorials downloaded from the Netbeans website do the same. When I close the application I'm left with a dead window. I then have to manually kill the process. It comes and goes, but I can't figure out what triggers this behavior.

I have also run my applications from the command line terminal using openjdk (6b12-0ubuntu6.1) and sun-java (6-10-0ubuntu2), still no luck. I have noticed when running it through netbeans after trying to close it netbeans still shows the app as running and after manually killing the process my netbeans log prints "Java Result: 137"

Update - 4Mar: I have also tried upgrading to Sun JDK 6u12 and Netbeans 6.7m2. But still no luck.

Update - 4Mar: Ok, after further testing I found that this behavior starts as soon as I add JPA to my application. That makes explains why the JPA tutorial examples on the netbeans website also do the same. I have tried writing an ExitListener to first close the EntityManager but no luck yet. If I delete the EntityManager, Query and List from my Form Panel the applications closes properly again.

+1  A: 

Have you looked at http://stackoverflow.com/questions/258099/how-to-close-a-java-swing-application-from-the-code yet?

chadwick
I have yes. Thank you. Like I said even the out of the box examples on the Netbeans website does the same.
Christo Du Preez
+1  A: 

make sure you call setDefaultCLoseOperation(JFrame.EXIT_ON_CLOSE);

TofuBeer
A: 

What minor release of Java 6 are you using? I was on update 10 I think and having a lot of issues on Ubuntu 8.10, upgrading to .12 helped a lot.

Tom Martin
I'm on 10 also. I'm going to do the upgrade and see if it works. I'm positive that this might just do the trick. Thanx
Christo Du Preez
A: 

This is caused by using the "System Default" or "GTKLookAndFeel" look and feel. I switched over to "NimbusLookAndFeel" and the issue disappeared.

I have tried all suggestions including Netbeans 6.7 and Java 6.12.

Still unclear as to why this is happening on Ubuntu 8.10.

Christo Du Preez