Java question

crazygal

Senior member
Feb 26, 2002
469
0
0
I'm doing my term project for my Java class and we're supposed to make a paint program. Right now I'm implementing the close feature (which should take about 2 seconds) but I cannot find a method in the api (JDK 1.3) for closing Frames.

The link for the api is here: API
If anyone could help I'd much appreciate it!
Thanks

(and to all of you who might say, "Do your own homework!", I honestly think that this is about .01% of the total project so take that!)
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: crazygal
I'm doing my term project for my Java class and we're supposed to make a paint program. Right now I'm implementing the close feature (which should take about 2 seconds) but I cannot find a method in the api (JDK 1.3) for closing Frames.

close as in... like you click on the X in the window and the application quits?
 

crazygal

Senior member
Feb 26, 2002
469
0
0
Yes, but if there's multiple frames open, I don't want them all to close (as in I don't want a system exit).

So it's just like clicking the X
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
My java class last semester used 1.4, but if my main window spawned a second JFrame, closing that one didn't affect the main window at all. You're not trying to close the main window and have windows that it spawned stay open, are you?
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: crazygal
Yes, but if there's multiple frames open, I don't want them all to close (as in I don't want a system exit).

So it's just like clicking the X

are you using JFrame or AWT?

well first you'll have to create a class that either implements WindowListener or extends WindowAdapter, and define a method for "public void windowClosing(WindowEvent e)" -- but I assume you've got that already.
 

crazygal

Senior member
Feb 26, 2002
469
0
0
Ok, I think I found it actually. frame.dispose() does what I want it to, but the description of it made it seem like it wouldn't work.

 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: KingNothing
My java class last semester used 1.4, but if my main window spawned a second JFrame, closing that one didn't affect the main window at all. You're not trying to close the main window and have windows that it spawned stay open, are you?
IMHO, if the main window close, you _should_ quit the program.. that's just normal program design, methinks.
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: crazygal
Ok, I think I found it actually. frame.dispose() does what I want it to, but the description of it made it seem like it wouldn't work.

yep, looks like despose() is what you want to do.
 

crazygal

Senior member
Feb 26, 2002
469
0
0
I'm actually using my own frame class that extends JFrame. Iceman, I think you got confused about what I was asking. If I have a windowListener then that's only called when I actually click the X myself. What I wanted was a menu item (basically a button) to simulate the clicking of the X (like when you do File/Close). This is, of course, different from File/Exit which would close all of the windows and exit the program instead of just the current frame
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: crazygal
I'm actually using my own frame class that extends JFrame. Iceman, I think you got confused about what I was asking. If I have a windowListener then that's only called when I actually click the X myself. What I wanted was a menu item (basically a button) to simulate the clicking of the X (like when you do File/Close). This is, of course, different from File/Exit which would close all of the windows and exit the program instead of just the current frame

ahh... okay, gotcha. Well, in either case you'd call dispose(), just that for clicking on a button you put the call to dispose() inside the listener for the button, whereas if you close the window with the X then the dispose() is called by the window manager.

Good luck with the rest of your project. I did a paint-like program for my software design course.. it was a fairly fun experience.
 

crazygal

Senior member
Feb 26, 2002
469
0
0
Thanks! It's fun but I've been sick these last 3 days and I have only 3 more days to complete an entire term project, crap!!!!
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Originally posted by: crazygal
Thanks! It's fun but I've been sick these last 3 days and I have only 3 more days to complete an entire term project, crap!!!!
:Q:Q D'oh!! Think through a design before you code.. a solid design will make the coding process less painful and more accurate. Feel free to PM me if you run into more questions, but your primary people resource should be your course staff.
 

crazygal

Senior member
Feb 26, 2002
469
0
0
Thanks cyrus and sambao but you both are misreading my question. Your code would exit the program (closing all windows) if any one of the windows was closed.

I was looking for code that would for only the current window to close, and not all of them. (Kinda like close versus exit). Thanks anyway though!

(by the way, the method is Frame.dispose() )
 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
hey crazygal, how's the program coming along? (heh.. I see you posting in the wee hours of the morning..) (on a friday night..)
 

crazygal

Senior member
Feb 26, 2002
469
0
0
It's not going well at all. I have no idea where to put these tools for the different shapes and the selection button but I'm sure I'll figure it out eventually. I'm just going to have literally no time to study for finals, oh well.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |