The Source for Java Technology Collaboration
User: Password:



Editor's Daily Blog

Avoiding the GridBag

Posted by daniel on July 22, 2003 at 06:25 AM | Comments (2)

The GridBagLayout is kind of the brocoli of the Swing layout managers. It's good for you, there are people who seem to really like it, but it's brocoli. In Java Today we feature a java.net project named packer. In many ways the new approach isn't much more accessible to new users but the code that a complex layout would require is greatly reduced.

Greg offers the following example of using GridBagLayout and GrigBagConstraint to layout a labeled text field that expands horizontally.

GridBagConstraints gc = new GridBagConstraints();
GridBagLayout gl = new new GridBagLayout();
Panel p = new Panel();
p.setLayout( gl );

Label l = new Label("Username:");

p.add(l);
gc.fill = GridBagConstraints.HORIZONTAL;
gc.weightx = 0;
gc.gridx = 0;
gl.setConstraints(l,gc);

TextField f = new TextField();
p.add(f);
gc.weightx = 1;
gc.gridx = 1;
gl.setConstraints(f,gc); 
 

Using his Packer class, the code can be simplified as follows.

 Panel p = new Panel();
 Packer pk = new Packer(p);
 Label l = new Label("Username:");
        
 TextField f = new TextField();
 pk.pack( l ).fillx().weightx(0).gridx(0);
 pk.pack( f ).fillx().gridx(1); 
 

You certainly use less code. Is it more readable or easier to use? Join the packer project and provide your feedback.

In Weblogs, Erb Cooper's debut entry has the provocative title Java 1.5: The end of Java?. Erb has learned to love the changes and additions to the Java language (such as anonymous inner classes) in the past. He's not looking forward to the changes coming in 1.5. His entry explains that the implementation of generics and the overloading of for feel very C-like to him and he worries what it will mean in this time that developers are weighing the use of Java against C#.

Marc Hadley's weblog entry W3C Announces Workshop on Binary Interchange of XML Information Item Sets points to what is currently a passworded link. Hadley details the fundamental issue that XML files are easier to read than binary but they are bulky. Hadley hopes that a binary representation of XML might help improve the performance of web services.

In the Also Today section, in addition to the packer project, we link to the JavaWorld article Add concurrent processing with message-driven beans. Amit Poddar shows how different models of concurrency can be applied to a J2EE application.

Steve Mallett, the Java Today news editor has gathered the following Java Today News Headlines : "Eclipse Stable Build: 3.0M2 Released", "Base Beans Announces basicPortal v 0.9.8", "LGPL reciprocity terms still unclear OSL and AFL licences offer closure", "Compuware adds Java modeling", "IceMail 4.0.2 Released", and "Book Review of Eclipse in Action".

Once this page is no longer featured as the front page of Java Today it will be archived at http://today.java.net/today/archive/index_07222003.html. You can access other past issues by changing the address appropriately.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • 网络营销软件
    网络营销软件
    网络营销软件
    群发软件
    群发软件
    ---
    群发软件
    网络营销软件网络推广软件网站推广软件下载引擎登陆软件论坛群发软件下载免费版
    论坛群发软件,信息群发软件,群发软件,网络营销软件,网站推广软件引擎登陆软件下载
    网站排名软件网站推广软件信息群发软件博客群发软件论坛群发软件免费下载
    群发软件,信息群发软件,博客群发软件,论坛群发软件,免费下载:群发软件系统
    推广小助手破解版
    论坛群发软件
    网站排名软件
    群发软件
    推荐给你很好的群发软件和信息群发软件和供求群发软件
    推荐给你很好的群发软件和信息群发软件和供求群发软件博客群发软件网络营销软件网络营销软件
    网站排名软件网站排名软件网站优化软件信息群发软件信息群发软件信息群发软件论坛群发软件网站推广软件网站推广软件博客群发软件博客群发软件

    群发软件群发软件博客群发软件论坛群发软件网络营销软件论坛群发软件
    信息群发软件推广软件网站推广软件网络营销软件网站推广软件群发软件网站排名软件网站推广软件博客群发软件论坛群发软件群发软件网站排名软件网站推广软件博客群发软件论坛群发软件
    网站排名软件
    博客群发软件
    网站排名软件
    网站推广软件
    群发软件信息群发软件
    免费论坛群发软件
    论坛群发软件
    网站排名软件
    免费博客群发软件
    网站推广软件

    群发软件
    博客群发软件
    网站排名软件
    网站推广软件
    群发软件信息群发软件
    免费论坛群发软件
    论坛群发软件
    网站排名软件
    免费博客群发软件
    博客群发软件
    信息群发软件
    论坛群发软件
    信息群发软件
    博客群发软件
    qq群发软件
    邮件群发软件
    博客群建软件
    企业名录搜索软件
    信息群发软件
    邮件群发软件
    论坛群发软件
    博客群发软件
    网站推广软件
    网络营销软件
    全能营销破解版

    Posted by: xinxi123 on December 04, 2007 at 09:59 AM

  • 网络营销软件
    网络营销软件
    网络营销软件
    群发软件
    群发软件
    ---
    群发软件
    网络营销软件网络推广软件网站推广软件下载引擎登陆软件论坛群发软件下载免费版
    论坛群发软件,信息群发软件,群发软件,网络营销软件,网站推广软件引擎登陆软件下载
    网站排名软件网站推广软件信息群发软件博客群发软件论坛群发软件免费下载
    群发软件,信息群发软件,博客群发软件,论坛群发软件,免费下载:群发软件系统
    推广小助手破解版
    论坛群发软件
    网站排名软件
    群发软件
    推荐给你很好的群发软件和信息群发软件和供求群发软件
    推荐给你很好的群发软件和信息群发软件和供求群发软件博客群发软件网络营销软件网络营销软件
    网站排名软件网站排名软件网站优化软件信息群发软件信息群发软件信息群发软件论坛群发软件网站推广软件网站推广软件博客群发软件博客群发软件

    群发软件群发软件博客群发软件论坛群发软件网络营销软件论坛群发软件
    信息群发软件推广软件网站推广软件网络营销软件网站推广软件群发软件网站排名软件网站推广软件博客群发软件论坛群发软件群发软件网站排名软件网站推广软件博客群发软件论坛群发软件
    网站排名软件
    博客群发软件
    网站排名软件
    网站推广软件
    群发软件信息群发软件
    免费论坛群发软件
    论坛群发软件
    网站排名软件
    免费博客群发软件
    网站推广软件

    群发软件
    博客群发软件
    网站排名软件
    网站推广软件
    群发软件信息群发软件
    免费论坛群发软件
    论坛群发软件
    网站排名软件
    免费博客群发软件
    博客群发软件
    信息群发软件
    论坛群发软件
    信息群发软件
    博客群发软件
    qq群发软件
    邮件群发软件
    博客群建软件
    企业名录搜索软件
    信息群发软件
    邮件群发软件
    论坛群发软件
    博客群发软件
    网站推广软件
    网络营销软件
    全能营销破解版

    Posted by: xinxi123 on December 04, 2007 at 10:25 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds