Results 1 to 2 of 2
- 10-31-2010, 08:30 PM #1Member
- Join Date
- Oct 2010
- Rep Power
New to Swing, need some advice on programming style
I've been trying to build a GUI for a school project, but my code is starting to look very messy and I'm starting to think I've done something wrong. At the moment, I have one GUI class that contains all my jPanels (I'm using cardlayout), button functionality, etc... and it's become quite large because of all the items in there and all the layout code for each separate panel.
So, I was wondering if this is a normal occurrence or if I should place all my jpanels in different classes and somehow make them still work together (I tried once and failed, but if that's the way to go I'll just try again) or if there's a better way I haven't thought of yet.
I think that in general it's often good code practice to refactor up large bulky classes into smaller classes that hold logical units of code. This can reduce redundancy and make code much easier to debug.
With regards to communication between classes -- it's the same for GUI as it is for non-GUI code. You'll tend to use an observer type pattern though when doing event-driven programming.
- By alacn in forum Jobs DiscussionReplies: 1Last Post: 08-18-2010, 12:53 PM
- By Aldius in forum New To JavaReplies: 10Last Post: 10-23-2009, 01:51 AM
- By makpandian in forum AWT / SwingReplies: 2Last Post: 02-28-2009, 09:02 AM
- By smart in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 12-27-2008, 06:25 PM
- By xcallmejudasx in forum New To JavaReplies: 2Last Post: 12-09-2008, 06:02 PM