Saturday, May 25th

Last update09:16:19 PM GMT

Add Announcement Here

Extending JFrame VS Instantiating

Extending JFrame VS Instantiating

Hello everyone, i want to know your opinions on this issue.
In creating GUI's in java desktop apps, you can either instantiate the JFrame class or create a class that extends JFrame.
Which of there is much more efficient or in what situation is one method better than the other.

elimence
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Re: Extending JFrame VS Instantiating

Basically it depends on the situation. And the word better should have it sense .
extending JFrame or using an instance to attach control are almost at the same level of performance.
The key is how easy its going to be for you.
if you need to have many controls in the window it's easier to extend because you will end up having many GUI code so it make send to put in one place (e.i in the JFrame class)
if you need one single control you can use an instance of JFrame. the last case is rarely used in pro apps that's even why most GUI designer alwayse extend JFrame , Form (c#) or
QMainWindow (qt) so I would advise you to take that approach. However remember to not put all your event handlers in you GUI code .
Always try to apply the principle of separation of concern. Also too many private class that are generated by direct implementation of ActionListner make your app slow.

I hope that help.

Evanxg
useravatar
Offline
2 Posts
User info in posts
Administrator has disabled public posting

Re: Extending JFrame VS Instantiating

Yah, thanks a lot, makes a lot of sense to me.

elimence
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
117
Total Polls:
0
Total Posts:
463
Dormant:
User Info:
 
Total Users:
1297
Newest User:
margaret0
Members Online:
0
Guests Online:
114

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked

Contact us

  • Add: 554 N Frederick Avenue Suite 216,
    Gaithersburg, MD 20877 USA
  • Tel: (888) 418-1146
You are here: Java General discussion Extending JFrame VS Instantiating