Subscribe to The Way I See It        RSS Feed
-----

GUI Crafting

Icon Leave Comment
In Java, there is only one right way to develop a GUI--by hand. No other road is acceptable in our realm. For reason I won't get into here, the Netbeans Generator is frowned upon by all respectable programmers. Here are a few tips to keep in mind when developing your own GUI:

Tip #1: Always Use A Constructor
I cannot emphasize this enough. The constructor of your class is the only place you should ever create your GUI. any other way is extremely sloppy coding practice (not to mention potentially bug ridden for your program. That's what constructors are for--setting up the class before it is used

Tip #2: Use Swing, Not AWT
Not that there is anything wrong with AWT, but Sun upgraded their components and containers for a reason. Swing components/containers are more compact and efficient with less overhead than it's predecessor

Tip #3: Use Layout Managers
Sun has provided many Layout Managers to ease the arrangement process of a GUI. Often, this is the most time-consuming process. Keep in mind that you can have more than one Layout used throughout the GUI. You simply utilize this though:

container.setLayout(new BorderLayout());//or whatever layout you need for the task
container2.setLayout(new GridLayout());



These are the two layouts I use the most. I leave it up to you to research these things
piece of cake :bigsmile:


Tip #4: Swing Is NOT Thread Safe
If you are creating a program which requires certain processes in your GUI to occur at specific intervals, don't use Thread.sleep() to make it happen. Look into Swing Timers

If anybody else has useful tips, please comment and I will add them to the list. Brief tips that help guide new GUI programmers to useful resources or information

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

September 2014

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
2829 30     

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)