• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] JFrame and peerless components

This topic is 5269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

for a pretty simple interactive program i''m writing, which is almost entirely swing based, im subclassing JFrame to both make my window and set up the two or three classes (which in turn extend JPanel) that interact within that window. however, i was just reading about swing components being peerless and all, and how JFrame and JWindow are the only swing components that arent lightweight. so, my question is, does it really matter that i am subclassing jframe directly? its easier for me for customization purposes, i only need one set of defining variables, etc, but i dont want to mess with swing''s whole interface with AWT. am i going to cause any problems or am i worrying needlessly? thanks, justo

Share this post


Link to post
Share on other sites
Advertisement
I subclass JFrame all the time, everyone does really. The fact that it''s heavyweight isn''t really relevant here, it''s always top level, and Sun obviously designed it with the idea that you''d be adding lightweight components to it.

Although most of the time there''s no real reason to subclass JFrame beyond a bit of convenience. JFrame''s designed well enough to be almost completely usable from the outside. It''s up to you I guess.

Share this post


Link to post
Share on other sites
All that heavyweight means is that the component drawn using the OSes own widgets. AWT is all heavy weight, Swing is almost all lightweight. The reason JFrame and JWindow are heavyweight is because they are the anchor into the OSes GUI.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites

  • Advertisement