gridbaglayout

Neil Benn neil.benn at arcor.de
Tue Dec 21 00:11:41 CET 2004


python473 at yahoo.com wrote:

>Friends - I have tried to do abolute positioning using gridbaglayout,
>but am having no success in jython. One book I have been referencing
>says that it only works with JPanels. Could someone post a snippet of
>code that works for a button? I am so close so just a hint would help.
>Thanks as always. - John
>
>  
>
Hello,

          Two points :

Don't use GridBagLayout - it's horrible, you can nearly always use the 
other layouts (BorderLayour, Flow Layout, BoxLayout and GridLayout are 
teh most common ones to use) will get you far far further then 
GridBagLayout.  GridBagLayout is from the old old days - a secret is, 
don't be afraid to nest layouts.

Don't use absolute positioning - Absolute positioning is a real pain, 
isn't well supported and doesn't scale on different resolutions properly..

    Sorry to send a message with two don'ts in it but it's an easy 
mistake to make at first (I did it too!) and you need to avoid doing 
this.  If you want some good examples of Java coding then a good 
resource is Javaworld  (http://www.javaworld.com).  At first you need to 
get a feel for LayoutManagers but once you have you can knock stuff 
together pretty well.  If you get stuck then use an IDE such as JBuilder 
at furst but don't rely on this too much as it can end up writing a lot 
of code you can;t really get stuck into to make your app more 
responsive/smoother coded.

    Finally if you are new then check out the Swing tutorial on the Java 
tutorials site by sun - that can give you some good starters.

Cheers,

Neil




More information about the Python-list mailing list