• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to add functionality in dialog window

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"

 
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my experience, close, minimize and maximize work automatically when you extend JFrame
 
Greg Charles
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79974
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I think the default is "HIDE_ON_CLOSE".
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic