Why do my Swing application windows intermittently not close when the application exits?

1k views Asked by At

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.

3

There are 3 answers

0
Dupdroid On BEST ANSWER

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.

0
TofuBeer On

make sure you call setDefaultCLoseOperation(JFrame.EXIT_ON_CLOSE);

1
Tom Martin On

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.