• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tidy UI code...

 
Ronnie McBob
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This assignment is probably the biggest thing that I've written in Java so far.. and I have little real life experience of using Swing.

I'm finding that the UI code that I am writing seems to be getting a little messy. I've used Factory classes to create all my components so as to keep the code as tidy as possible.

The way that I am creating the UI is by putting components such as buttons and text fields into panels and then putting these panels into other panels etc etc.. so there is a whole section of code where I am just putting all the components together. Is this the way to do it? Or should I create classes that represent these panels? e.g. TheSearchOptionsPanel class etc etc... this would segment my code into classes that may look a little neater. Good or bad idea?

What is the "Java" way of doing this?

Thanks,

Ron
 
Anton Golovin
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ronnie McBob:
This assignment is probably the biggest thing that I've written in Java so far.. and I have little real life experience of using Swing.

I'm finding that the UI code that I am writing seems to be getting a little messy. I've used Factory classes to create all my components so as to keep the code as tidy as possible.

The way that I am creating the UI is by putting components such as buttons and text fields into panels and then putting these panels into other panels etc etc.. so there is a whole section of code where I am just putting all the components together. Is this the way to do it? Or should I create classes that represent these panels? e.g. TheSearchOptionsPanel class etc etc... this would segment my code into classes that may look a little neater. Good or bad idea?

What is the "Java" way of doing this?

Thanks,

Ron



Hi, Ron. In my project I strove to put all the visual elements (except configuration dialog) into one class. The simpler the better. The assessor will appreciate it, too, I think: the less work for him.

I am no expert of Swing also, but Swing code is messy by default; if not, the developer has outdone himself. Mine is pretty messy, and commented throughout so as to minimize the mess.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic