Results 1 to 2 of 2
  1. #1
    Gorgro is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

Similar Threads

  1. Replies: 1
    Last Post: 08-18-2010, 11:53 AM
  2. Long boolean coding style
    By Aldius in forum New To Java
    Replies: 10
    Last Post: 10-23-2009, 12:51 AM
  3. Framework for swing programming
    By makpandian in forum AWT / Swing
    Replies: 2
    Last Post: 02-28-2009, 08:02 AM
  4. Cascading Style Sheets
    By smart in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-27-2008, 05:25 PM
  5. Replies: 2
    Last Post: 12-09-2008, 05:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •