The Artima Developer Community
Sponsored Link

Java Buzz Forum
Avoiding the GridBag ... reminds me of GridBagPanel

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Brown

Posts: 636
Nickname: simonbrown
Registered: Jun, 2003

Simon Brown is a Java developer, architect and author.
Avoiding the GridBag ... reminds me of GridBagPanel Posted: Jul 22, 2003 3:02 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Simon Brown.
Original Post: Avoiding the GridBag ... reminds me of GridBagPanel
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
Latest Java Buzz Posts
Latest Java Buzz Posts by Simon Brown
Latest Posts From Simon Brown's weblog

Advertisement

Scanning through JavaBlogs, I came across a blog entry from java.net entitled Avoiding the GridBag that talks about the packer project - a way to simplify the GridBag API. This reminded me of a cool little component that I created for a Swing project a few years ago.

If you've done any Swing programming, you'll know that building forms in Swing can be a tricky process, especially if you decide to use the infamous GridBag layout manager. To make this task easier, I created a GridBagPanel - essentially a Swing JPanel that has GridBag set as its layout manager. GridBagPanel provides a very simple API that can be used to build forms (like the one shown below) very easily.

A form created using GridBagPanel

The following code sample shows how simple it is to build a form like this.


	// create the components as usual
	JTextField toTextField = new JTextField();
	JTextField ccTextField = new JTextField();
	JTextField subjectTextField = new JTextField();
	JTextArea messageTextArea = new JTextArea(4, 32);

	// then build a GridBagPanel, 4 rows by 2 columns
	GridBagPanel p = new GridBagPanel(4, 2);

	// and finally add rows specifying the label and the component
	p.addRow("To", toTextField);
	p.addRow("CC", ccTextField);
	p.addRow("Subject", subjectTextField);
	p.addRow("Message", new JScrollPane(messageTextArea));

I had completely forgotten about that until the packer project came up, so perhaps I should dig out the source code and make it availble under an open source license. Anybody think there's a demand for this sort of stuff? I also have a whole framework for building standardised dialogs and panels that conform to the Java Look and Feel guidelines if I can find it! I have the slides from a BOF that I gave at JavaOne 2000 about this stuff and I'm sure I have the code somewhere.

Read: Avoiding the GridBag ... reminds me of GridBagPanel

Topic: Microedition.platfoirm String-J2ME Previous Topic   Next Topic Topic: Mike Hogan's maintainability patterns

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use