This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Question about programming style Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question about programming style" Watch "Question about programming style" New topic
Author

Question about programming style

Greg Ferguson
Ranch Hand

Joined: Jun 04, 2012
Posts: 34
When creating a gui application or an applet, is there a standard about the best way to set up the code? For example, is it better to layout the code like this?

or like this:
Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 186
Don't know about the standard but prefer this one...

Buenny Fry wrote:
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
I can think of good reasons to prefer either. I'm not aware of a standard though. The important thing is to be consistent.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

I prefer the solution that uses a proper layout manager


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jordan D. Williams
Ranch Hand

Joined: Jan 03, 2012
Posts: 51

Rob Spoor wrote:I prefer the solution that uses a proper layout manager


What do you mean by that? (A beginner Java guy here...)

Thank you.


John 3:16
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html
Greg Ferguson
Ranch Hand

Joined: Jun 04, 2012
Posts: 34
Thanks for your replies. I wasn't sure if there was a standard, but I definitely agree about being consistent with whichever style is chosen. And thanks for that informative link Rob. I've already run into how complex using layout managers can be -- especially when you start combining them -- but that site helped me understand them better.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You're welcome
 
jQuery in Action, 2nd edition
 
subject: Question about programming style
 
Similar Threads
Reference Specific Line in Text File
It doesnt see my 'if' statements
JPanels with different content should have the same size
JScrollPane: Change of the size of content
Blank Frame or Panel