File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JDialog Dilemma I Have Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog Dilemma I Have" Watch "JDialog Dilemma I Have" New topic

JDialog Dilemma I Have

Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Here's a simple problem that I know most of you guys would know the answer in an instant, and willing to help your humankind.

I have a JDialog. On it is a JButton.
I want this JDialog to be modal, I set it to setModal(true).
Fair enough.
I have an actionEvent for the JButton press.

The problem is, because it's set to Modal, it won't process the actionEvent.

What I am trying to do here is make a JDialog with a JButton (the easiest part). It must be modal so the the JButton must be pressed to close this JDialog (call it dialog1). It then creates another JDialog (call it dialog2). This dialog2 has a Jbutton, which also must be pressed to close it.

Very familiar. Hoepfully lots of you there would provide help.

Thanks much, guys!

amerzil co-ed student<br />"Praise be the Code"
Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Hi guys!

I can close it now. However, in the JDialog is a JTextArea,
how do I handle the event (and which method) when there is no text input to the JTextArea?

I don't want the JDialog to close if the JTextArea is blank.
Giovanni De Stefano
Ranch Hand

Joined: Aug 17, 2004
Posts: 154
Hi Karen,
it's fairly simple: before you close the JDialog you have to check if there is no text input in the JTextArea, you simply do this checking if the getText() method of JTextArea returns an empty string or not.

I hope this helps.


SCJP 1.4
I agree. Here's the link:
subject: JDialog Dilemma I Have
jQuery in Action, 3rd edition