Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3715 > unrolled thread
| Started by | "mrstephengross" <mrstephengross@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:46 +0000 |
| Last post | 2011-04-27 15:46 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.java.gui
Weird window close behavi "mrstephengross" <mrstephengross@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
Re: Weird window close be "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
Re: Weird window close be "mrstephengross" <mrstephengross@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
Re: Weird window close be "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
| From | "mrstephengross" <mrstephengross@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:46 +0000 |
| Subject | Weird window close behavi |
| Message-ID | <808824ce-150d-4b52-a923-314860c60438@j22g2000hsf.googlegroups.com> |
To: comp.lang.java.gui
I have a short swing program (see below) that dislpays a HelloWorld
frame. It compiles fine, but runtime behavior is a bit awkward. To
wit:
(1) I run the program. It shows a nice 100x100 empty panel. I move the
mouse directly over the CLOSE button (the top-right "X") WITHOUT
moving over the content pane at all. I click the close button. The
window closes.
(2) I run the program. It shows a nice 100x100 empty panel. I move the
mouse first over the content pane, THEN over the CLOSE button and
click it. The window does NOT close.
This is indeed weird behavior. I wonder if it has anything to do with
my system configuration. I am running:
OS: Ubuntu 6
Javac: gcj-4.2 (GCC) 4.3.2 (Ubuntu 4.2.3-2ubuntu6)
java: "1.5.0" gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)
Any ideas?
=== CODE FOLLOWS ===
import javax.swing.JFrame;
public class HelloWorldFrame {
public static void main(String args[]) {
new HelloWorldFrame();
}
HelloWorldFrame() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100, 100);
frame.setVisible(true);
}
}
=== EOF ===
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:46 +0000 |
| Subject | Re: Weird window close be |
| Message-ID | <4863f5b0$0$32040$7836cce5@newsrazor.net> |
| In reply to | #3715 |
To: comp.lang.java.gui
mrstephengross wrote:
> I have a short swing program (see below) that dislpays a HelloWorld
> frame. It compiles fine, but runtime behavior is a bit awkward. To
> wit:
>
> (1) I run the program. It shows a nice 100x100 empty panel. I move the
> mouse directly over the CLOSE button (the top-right "X") WITHOUT
> moving over the content pane at all. I click the close button. The
> window closes.
>
> (2) I run the program. It shows a nice 100x100 empty panel. I move the
> mouse first over the content pane, THEN over the CLOSE button and
> click it. The window does NOT close.
>
> This is indeed weird behavior. I wonder if it has anything to do with
> my system configuration. I am running:
> OS: Ubuntu 6
> Javac: gcj-4.2 (GCC) 4.3.2 (Ubuntu 4.2.3-2ubuntu6)
> java: "1.5.0" gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)
>
> Any ideas?
>
> === CODE FOLLOWS ===
> import javax.swing.JFrame;
>
> public class HelloWorldFrame {
>
> public static void main(String args[]) {
> new HelloWorldFrame();
> }
> HelloWorldFrame() {
> JFrame frame = new JFrame();
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> frame.setSize(100, 100);
> frame.setVisible(true);
> }
> }
> === EOF ===
It is possible that because you didn't create the JFrame instance in the
Event Dispatch Thread, you've cause some strange race condition.
Always make sure you are in the EDT. If you know you're not, or aren't
sure, use EventQueue.invokeLater(...) to ensure your code is in the EDT.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "mrstephengross" <mrstephengross@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:46 +0000 |
| Subject | Re: Weird window close be |
| Message-ID | <f2031a5d-755b-47e1-b609-0c8fa94db9b7@k37g2000hsf.googlegroups.com> |
| In reply to | #3717 |
To: comp.lang.java.gui
> It is possible that because you didn't create the JFrame instance in the
> Event Dispatch Thread, you've cause some strange race condition.
> Always make sure you are in the EDT. If you know you're not, or aren't
> sure, use EventQueue.invokeLater(...) to ensure your code is in the EDT.
Ok, I looked up stuff on EDT and amended my code to use it (see
below). However, the weird behavior still persists. Have I implemented
it incorrectly?
=== CODE FOLLOWS ===
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class HelloWorldFrame {
public static void main(String args[]) {
new HelloWorldFrame();
}
HelloWorldFrame() {
Runnable doWorkRunnable = new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100, 100);
frame.getContentPane().add(new
JLabel("hi"));
frame.setVisible(true);
}
};
SwingUtilities.invokeLater(doWorkRunnable);
}
}
=== EOF ===
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:46 +0000 |
| Subject | Re: Weird window close be |
| Message-ID | <c96i64pp95g2upoikfu40cj08sonf253ie@4ax.com> |
| In reply to | #3715 |
To: comp.lang.java.gui
On Thu, 26 Jun 2008 12:27:16 -0700 (PDT), mrstephengross
<mrstevegross@gmail.com> wrote, quoted or indirectly quoted someone
who said :
>import javax.swing.JFrame;
>
>public class HelloWorldFrame {
>
> public static void main(String args[]) {
> new HelloWorldFrame();
> }
> HelloWorldFrame() {
> JFrame frame = new JFrame();
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> frame.setSize(100, 100);
> frame.setVisible(true);
> }
>}
When I run your program under Vista I don't see this behaviour. Sounds
like a bug in your JVM. Try submitting your sscce to whomever wrote
it.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web