This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to add functionality in dialog window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to add functionality in dialog window" Watch "how to add functionality in dialog window" New topic
Author

how to add functionality in dialog window

Mike John
Greenhorn

Joined: Mar 25, 2013
Posts: 1
Hello, i am new to AWT.

created the login window.

Question is how to add the following

1) Dialog window should disappear when click on "X"
2) Dialog window should minimize when click on "-"
3) Dialog window should maximize when click on "="
4) Dialog window should disappear when click on "Cancel"

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Welcome to JavaRanch!

Are you sure you want to be using AWT? Swing succeeded AWT about 15 years ago for Java GUI development.

For your questions:

1. By X, do you mean the X close link in the upper right corner of the Frame? If so, I don't remember.
2. Use a KeyListener.
3. The same KeyListener as 2.
4. An ActionListener.

Those aren't detailed answers I know, but they point you in the right direction. You should give it your best try, and if you get stuck somewhere, we'll be here to answer any more specific questions you might have.

If you have a chance, please see ShowSomeEffort (⇐Click) from the JavaRanch FAQ.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

in my experience, close, minimize and maximize work automatically when you extend JFrame


SCJP
Visit my download page
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Really? I remember having to implement a WindowListener to close a JFrame, but the exact recommended procedure kept changing, and then I stopped working with Swing. However, Mike is using and old-old-school AWT Frame. I really can't remember how those worked at all.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
I think it is the same: you add a window listener to the frame, and in its closing or closed methods you put the appropriate code to shut down the app.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2154
    
    7


I think the default is "HIDE_ON_CLOSE".
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Mike John, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/awt-swing/70702-how-add-functionality-dialog-window.html


luck, db
There are no new questions, but there may be new answers.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

Rob got it. i forgot that i had to have that line
as for AWT Frame, i have never used that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to add functionality in dialog window
 
Similar Threads
Result set type is TYPE_FORWARD_ONLY
applet to applet communication
Database ...need to implement
Focussing a TextField
Help,Components inside my Frame would not be displayed until maximized.