Results 1 to 3 of 3
Thread: A frame and a dialog
- 03-18-2009, 05:50 AM #1
Senior Member
- Join Date
- Nov 2007
- Posts
- 160
- Rep Power
- 6
A frame and a dialog
Say I have a JFrame with a button in it. I want a JDialog to appear when I click the button.
I could do this by writing another class that creates the JDialog and then by making an object of that class from my main class with the JFrame. But could I not also just create the JDialog in the original class? It wouldn't look very nice obviously; the JDialog is about 40 lines long. Is that the only reason for not wanting to do so?
My question is, should you separate code into classes for purely 'aesthetic' seasons?
-
If the dialog were simple and quite obviously dependent on the calling class, and also obviously that this will not change in the forseeable future, then I don't see any problem with keeping the code within the calling class if the class isn't too big. otherwise, it would be better to place the other GUI code in another class.
A note here though: I almost always create the JDialog object itself in the calling class since this creation usually needs to be controlled by the calling class, but I place the code that creates the JPanel that will serve as the JDialog's contentPane in its own class.
- 03-18-2009, 09:22 PM #3
Senior Member
- Join Date
- Nov 2007
- Posts
- 160
- Rep Power
- 6
Similar Threads
-
GUI new frame
By billbo123 in forum New To JavaReplies: 15Last Post: 03-02-2009, 04:24 AM -
frame
By arunkumarinfo in forum NetBeansReplies: 0Last Post: 02-07-2009, 10:26 AM -
Frame to other Frame
By Aswq in forum New To JavaReplies: 2Last Post: 07-19-2008, 04:27 PM -
Example of SWT Dialog
By Java Tip in forum Java TipReplies: 0Last Post: 01-09-2008, 12:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks