Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to add functionality in dialog window

 
Mike John
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4369
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my experience, close, minimize and maximize work automatically when you extend JFrame
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2559
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I think the default is "HIDE_ON_CLOSE".
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike John, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/awt-swing/70702-how-add-functionality-dialog-window.html
 
Randall Twede
Ranch Hand
Posts: 4369
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob got it. i forgot that i had to have that line
as for AWT Frame, i have never used that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic