Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2224 > unrolled thread

GroupLayout problem, jbut

Started by"Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this>
First post2011-04-27 15:37 +0000
Last post2011-04-27 15:38 +0000
Articles 11 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  GroupLayout problem, jbut "Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
    Re: GroupLayout problem, "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
      Re: GroupLayout problem, "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
        Re: GroupLayout problem, "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
          Re: GroupLayout problem, "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
    Re: GroupLayout problem, "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
      Re: GroupLayout problem, "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
        Re: GroupLayout problem, "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
          Re: GroupLayout problem, "Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this> - 2011-04-27 15:38 +0000
            Re: GroupLayout problem, "Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this> - 2011-04-27 15:38 +0000
              Re: GroupLayout problem, "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:38 +0000

#2224 — GroupLayout problem, jbut

From"Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectGroupLayout problem, jbut
Message-ID<46c00dce$0$5090$ba4acef3@news.orange.fr>
  To: comp.lang.java.gui
Hello,

I have a JPanel subclass with swing components on it. I don't manage to 
put the button at the left of the panel. Why ?

Here is a simplified version of the source code:

=========================== >8 =====
package java_;

import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class TestGroupLayout extends JPanel {

   public TestGroupLayout() {
     init();
   }

   private void init() {
         jLabel1 = new javax.swing.JLabel("l1");
         combo1 = new javax.swing.JComboBox();
         jLabel2 = new javax.swing.JLabel("l2");
         combo2 = new javax.swing.JComboBox();
         jLabel3 = new javax.swing.JLabel("l3");
         spinner = new javax.swing.JSpinner();
         check = new JCheckBox("check");
         button = new JButton("bouton");

         org.jdesktop.layout.GroupLayout layout = new 
org.jdesktop.layout.GroupLayout(this);
         this.setLayout(layout);
         layout.setHorizontalGroup(
 
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(layout.createSequentialGroup()
                 .addContainerGap()
 
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, 
false)
                     .add(check)
                     .add(layout.createSequentialGroup()
                         .add(jLabel1)
 
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                         .add(combo1, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                     .add(layout.createSequentialGroup()
                         .add(jLabel2)
 
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                         .add(combo2, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                     .add(layout.createSequentialGroup()
                         .add(jLabel3)
 
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                         .add(spinner, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                     .add(button)
 
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE))
         );
         layout.setVerticalGroup(
 
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(layout.createSequentialGroup()
                 .addContainerGap()
                .add(check)
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
 
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel1)
                     .add(combo1, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
 
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel2)
                     .add(combo2, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
 
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel3)
                     .add(spinner, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                 .add(button)
 
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE))
         );

   }

     public static void main(String[] args) {
       EventQueue.invokeLater(new Runnable() {
         public void run() {
           JFrame f = new JFrame();
           f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
           f.setContentPane(new TestGroupLayout());
           f.pack();
           f.setVisible(true);
         }
       });
     }

     private JButton button;
     protected JCheckBox check;
     private javax.swing.JComboBox combo1;
     private javax.swing.JComboBox combo2;
     private javax.swing.JLabel jLabel1;
     private javax.swing.JLabel jLabel2;
     protected javax.swing.JLabel jLabel3;
     protected javax.swing.JSpinner spinner;

}
=========================== >8 =====

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2232 — Re: GroupLayout problem,

From"hiwa" <hiwa@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<1187151242.728925.229760@g12g2000prg.googlegroups.com>
In reply to#2224
  To: comp.lang.java.gui
On Aug 13, 4:52 pm, "Kaiser S." <sau...@name.invalid> wrote:
> Hello,
>
> I have a JPanel subclass with swing components on it. I don't manage to
> put the button at the left of the panel. Why ?
>
> Here is a simplified version of the source code:
>
> =========================== >8 =====
> package java_;
>
> import java.awt.EventQueue;
>
> import javax.swing.JButton;
> import javax.swing.JCheckBox;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
>
> public class TestGroupLayout extends JPanel {
>
>    public TestGroupLayout() {
>      init();
>    }
>
>    private void init() {
>          jLabel1 = new javax.swing.JLabel("l1");
>          combo1 = new javax.swing.JComboBox();
>          jLabel2 = new javax.swing.JLabel("l2");
>          combo2 = new javax.swing.JComboBox();
>          jLabel3 = new javax.swing.JLabel("l3");
>          spinner = new javax.swing.JSpinner();
>          check = new JCheckBox("check");
>          button = new JButton("bouton");
>
>          org.jdesktop.layout.GroupLayout layout = new
> org.jdesktop.layout.GroupLayout(this);
>          this.setLayout(layout);
>          layout.setHorizontalGroup(
>
> layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
>              .add(layout.createSequentialGroup()
>                  .addContainerGap()
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
> false)
>                      .add(check)
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel1)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(combo1,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel2)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(combo2,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel3)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(spinner,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
>                      .add(button)
>
> .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> Short.MAX_VALUE))
>          );
>          layout.setVerticalGroup(
>
> layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
>              .add(layout.createSequentialGroup()
>                  .addContainerGap()
>                 .add(check)
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel1)
>                      .add(combo1,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel2)
>                      .add(combo2,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel3)
>                      .add(spinner,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                  .add(button)
>
> .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> Short.MAX_VALUE))
>          );
>
>    }
>
>      public static void main(String[] args) {
>        EventQueue.invokeLater(new Runnable() {
>          public void run() {
>            JFrame f = new JFrame();
>            f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
>            f.setContentPane(new TestGroupLayout());
>            f.pack();
>            f.setVisible(true);
>          }
>        });
>      }
>
>      private JButton button;
>      protected JCheckBox check;
>      private javax.swing.JComboBox combo1;
>      private javax.swing.JComboBox combo2;
>      private javax.swing.JLabel jLabel1;
>      private javax.swing.JLabel jLabel2;
>      protected javax.swing.JLabel jLabel3;
>      protected javax.swing.JSpinner spinner;
>
> }
>
> =========================== >8 =====

We got compiler errors:
TestGroupLayout.java:33: package org.jdesktop.layout does not exist
         org.jdesktop.layout.GroupLayout layout = new
                            ^
TestGroupLayout.java:34: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout(this);
                   ^
TestGroupLayout.java:71: package org.jdesktop.layout does not exist
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    ^
TestGroupLayout.java:66: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:67: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:68: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                   ^
TestGroupLayout.java:64: package org.jdesktop.layout does not exist
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    ^
TestGroupLayout.java:58: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:59: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:60: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                   ^
TestGroupLayout.java:56: package org.jdesktop.layout does not exist
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    ^
TestGroupLayout.java:50: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:51: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:52: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                   ^
TestGroupLayout.java:48: package org.jdesktop.layout does not exist
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    ^
TestGroupLayout.java:42: package org.jdesktop.layout does not exist
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
                                                   ^
TestGroupLayout.java:38: package org.jdesktop.layout does not exist
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                              ^
TestGroupLayout.java:107: package org.jdesktop.layout does not exist
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    ^
TestGroupLayout.java:104: package org.jdesktop.layout does not exist
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                     ^
TestGroupLayout.java:101: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:102: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:103: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                   ^
TestGroupLayout.java:98: package org.jdesktop.layout does not exist
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                                   ^
TestGroupLayout.java:96: package org.jdesktop.layout does not exist
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                     ^
TestGroupLayout.java:93: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:94: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:95: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                   ^
TestGroupLayout.java:90: package org.jdesktop.layout does not exist
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                                   ^
TestGroupLayout.java:88: package org.jdesktop.layout does not exist
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                     ^
TestGroupLayout.java:85: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                   ^
TestGroupLayout.java:86: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                   ^
TestGroupLayout.java:87: package org.jdesktop.layout does not exist
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                   ^
TestGroupLayout.java:82: package org.jdesktop.layout does not exist
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                                   ^
TestGroupLayout.java:80: package org.jdesktop.layout does not exist
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                     ^
TestGroupLayout.java:76: package org.jdesktop.layout does not exist
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                              ^
35 errors

Post a small demo code that is generally compilable, runnable and
could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html
and http://www.yoda.arachsys.com/java/newsgroups.html

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2233 — Re: GroupLayout problem,

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<76b73d92f1ed4@uwe>
In reply to#2232
  To: comp.lang.java.gui
hiwa wrote:
..
>We got compiler errors:
>TestGroupLayout.java:33: package org.jdesktop.layout does not exist
>         org.jdesktop.layout.GroupLayout layout = new
>                            ^
..
>35 errors

Yes, yes.  So did I.  But..
..
>Post a small demo code that is generally compilable, runnable and
>could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html
>and http://www.yoda.arachsys.com/java/newsgroups.html

.This person is trying to debug a particular layout, 
so it inherently requires that the end user (helper)
has access to this relatively common ..third party(?*)
layout.

* Is that the way to refer to the JDesktop API's?

To the OP.  hiwa's reply made me think of something
I considered mentioning when I first saw those same 
compile errors (..heck, it is much quicker to compile 
code and see errors, than read it and try and guess).
That is..
Perhaps there is a more specific forum for enquiring
about problems with GroupLayout.  As you can see,
it is not commonly used 'about these parts'.

Doesn't the JDesktop site have forums for the API's?
Maybe you'd have better luck on those.

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via http://www.javakb.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2234 — Re: GroupLayout problem,

From"hiwa" <hiwa@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<1187155629.818099.252400@e9g2000prf.googlegroups.com>
In reply to#2233
  To: comp.lang.java.gui
On Aug 15, 2:03 pm, "Andrew Thompson" <u32984@uwe> wrote:
> hiwa wrote:
>
> ..
>
> >We got compiler errors:
> >TestGroupLayout.java:33: package org.jdesktop.layout does not exist
> >         org.jdesktop.layout.GroupLayout layout = new
> >                            ^
> ..
> >35 errors
>
> Yes, yes.  So did I.  But..
> ..
>
> >Post a small demo code that is generally compilable, runnable and
> >could reproduce your problem. See:http://homepage1.nifty.com/algafield/sscce.html
> >andhttp://www.yoda.arachsys.com/java/newsgroups.html
>
> .This person is trying to debug a particular layout,
> so it inherently requires that the end user (helper)
> has access to this relatively common ..third party(?*)
> layout.
>
> * Is that the way to refer to the JDesktop API's?
>
> To the OP.  hiwa's reply made me think of something
> I considered mentioning when I first saw those same
> compile errors (..heck, it is much quicker to compile
> code and see errors, than read it and try and guess).
> That is..
> Perhaps there is a more specific forum for enquiring
> about problems with GroupLayout.  As you can see,
> it is not commonly used 'about these parts'.
>
> Doesn't the JDesktop site have forums for the API's?
> Maybe you'd have better luck on those.
>
> --
> Andrew Thompsonhttp://www.athompson.info/andrew/
>
> Message posted viahttp://www.javakb.com

Hi AT, nice to meet you.
I think the OP should have used javax.swing.GroupLayout from the start
because it is better than jdesktop one in design, implementation, and
among other things, documentation. The jdesktop one is hard to use
because of poor documentation.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2235 — Re: GroupLayout problem,

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<76b7b9aa69f35@uwe>
In reply to#2234
  To: comp.lang.java.gui
hiwa wrote:
..
>Hi AT, nice to meet you.

Are you not *the* hiwa that hosts the algafield 
version of the SSCCE?

In that case, I would have expected that statement to be..
"Hi AT, nice to meet you again."  ..or..
Hi AT, nice to talk to you again.

Oh, ..and nice talking to you, whether you're the 
hiwa I have known for a long time, or another 
person with same name!

>I think the OP should have used javax.swing.GroupLayout

(checks 1.6 docs.)  GroupLayout.. right.  Actually it was
the first time I had noticed it!  Thanks for the heads up.  :-)

>... from the start
>because it is better than jdesktop one in design, implementation, and
>among other things, documentation. The jdesktop one is hard to use
>because of poor documentation.

Uh-huhh.  I've used neither, so I'll take your word for it.

But - good idea.  I tried changing the imports directly
to the javax.swing.GroupLayout and LayoutStyle, but
the code required changes beyond that, before it would
compile.

OP - try it with the 1.6 Swing class, and get back to
us with an SSCCE if you cannot sort the problem (is
what I recommend).

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200708/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2236 — Re: GroupLayout problem,

From"hiwa" <hiwa@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<1187158313.718054.35840@x40g2000prg.googlegroups.com>
In reply to#2224
  To: comp.lang.java.gui
On Aug 13, 4:52 pm, "Kaiser S." <sau...@name.invalid> wrote:
> Hello,
>
> I have a JPanel subclass with swing components on it. I don't manage to
> put the button at the left of the panel. Why ?
>
> Here is a simplified version of the source code:
>
> =========================== >8 =====
> package java_;
>
> import java.awt.EventQueue;
>
> import javax.swing.JButton;
> import javax.swing.JCheckBox;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
>
> public class TestGroupLayout extends JPanel {
>
>    public TestGroupLayout() {
>      init();
>    }
>
>    private void init() {
>          jLabel1 = new javax.swing.JLabel("l1");
>          combo1 = new javax.swing.JComboBox();
>          jLabel2 = new javax.swing.JLabel("l2");
>          combo2 = new javax.swing.JComboBox();
>          jLabel3 = new javax.swing.JLabel("l3");
>          spinner = new javax.swing.JSpinner();
>          check = new JCheckBox("check");
>          button = new JButton("bouton");
>
>          org.jdesktop.layout.GroupLayout layout = new
> org.jdesktop.layout.GroupLayout(this);
>          this.setLayout(layout);
>          layout.setHorizontalGroup(
>
> layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
>              .add(layout.createSequentialGroup()
>                  .addContainerGap()
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
> false)
>                      .add(check)
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel1)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(combo1,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel2)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(combo2,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                      .add(layout.createSequentialGroup()
>                          .add(jLabel3)
>
> .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                          .add(spinner,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
>                      .add(button)
>
> .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> Short.MAX_VALUE))
>          );
>          layout.setVerticalGroup(
>
> layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
>              .add(layout.createSequentialGroup()
>                  .addContainerGap()
>                 .add(check)
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel1)
>                      .add(combo1,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel2)
>                      .add(combo2,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>
> .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
>                      .add(jLabel3)
>                      .add(spinner,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
> org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
>                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
>                  .add(button)
>
> .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
> Short.MAX_VALUE))
>          );
>
>    }
>
>      public static void main(String[] args) {
>        EventQueue.invokeLater(new Runnable() {
>          public void run() {
>            JFrame f = new JFrame();
>            f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
>            f.setContentPane(new TestGroupLayout());
>            f.pack();
>            f.setVisible(true);
>          }
>        });
>      }
>
>      private JButton button;
>      protected JCheckBox check;
>      private javax.swing.JComboBox combo1;
>      private javax.swing.JComboBox combo2;
>      private javax.swing.JLabel jLabel1;
>      private javax.swing.JLabel jLabel2;
>      protected javax.swing.JLabel jLabel3;
>      protected javax.swing.JSpinner spinner;
>
> }
>
> =========================== >8 =====
Yes, I am the man who translates cljg GUI FAQ in Japanese. :)
The below code needs some more elaboration but I think you could get
the basic idea for using Groups both for x-direction and y-direction.
Using both direction is the MUST for the GroupLayout.
-------------------------------------------------------------
import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class TestGroupLayoutX extends JPanel {

  public TestGroupLayoutX() {
    init();
  }

  private void init() {
    jLabel1 = new javax.swing.JLabel("l1");
    combo1 = new javax.swing.JComboBox();
    jLabel2 = new javax.swing.JLabel("l2");
    combo2 = new javax.swing.JComboBox();
    jLabel3 = new javax.swing.JLabel("l3");
    spinner = new javax.swing.JSpinner();
    check = new JCheckBox("check");
    button = new JButton("bouton");

    org.jdesktop.layout.GroupLayout layout = new
      org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);

    org.jdesktop.layout.GroupLayout.SequentialGroup hGroup
      = layout.createSequentialGroup();
 
hGroup.add(layout.createParallelGroup().add(check).add(jLabel1).add(jLabel2).add(jLabel3).add(button)).
 
add(layout.createParallelGroup().add(combo1).add(combo2).add(spinner));
    layout.setHorizontalGroup(hGroup);

    org.jdesktop.layout.GroupLayout.SequentialGroup vGroup =
layout.createSequentialGroup();
 
vGroup.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(check)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel1).add(combo1)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel2).add(combo2)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel3).add(spinner)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(button));
    layout.setVerticalGroup(vGroup);
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setContentPane(new TestGroupLayoutX());
        f.pack();
        f.setVisible(true);
        }
        });
  }

  private JButton button;
  protected JCheckBox check;
  private javax.swing.JComboBox combo1;
  private javax.swing.JComboBox combo2;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  protected javax.swing.JLabel jLabel3;
  protected javax.swing.JSpinner spinner;
}
---------------------------------------------

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2237 — Re: GroupLayout problem,

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<76b81edcb6545@uwe>
In reply to#2236
  To: comp.lang.java.gui
hiwa wrote:
..
>Yes, I am the man who translates cljg GUI FAQ in Japanese. :)

(chuckles) I hate to admit this, but despite knowing
you so long, and so 'well' (through our conversations
on usenet) but now is the first moment I could identify
you as a 'man' rather than simply a 'person'!

I had always been very careful to refer to you as 
'hiwa' or 'the last poster' or using other, non gender 
specific references to you, or things you wrote.

Of course, it is always a good idea to not jump to 
conclusions, and refer to people generically.  
After all, it is all about *what* they say, rather 
than *who* (other people might think) they are*.

Hope the OP has more luck with your code..

* And as an aside, I am a (male) 'Jack Russell' Terrier
.but don't hassle me about it, or I'll bite ya'.   ;-)

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200708/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2240 — Re: GroupLayout problem,

From"hiwa" <hiwa@THRWHITE.remove-dii-this>
Date2011-04-27 15:37 +0000
SubjectRe: GroupLayout problem,
Message-ID<1187179060.063613.31160@i13g2000prf.googlegroups.com>
In reply to#2237
  To: comp.lang.java.gui
On Aug 15, 3:44 pm, "Andrew Thompson" <u32984@uwe> wrote:
> hiwa wrote:
>
> ..
>
> >Yes, I am the man who translates cljg GUI FAQ in Japanese. :)
>
> (chuckles) I hate to admit this, but despite knowing
> you so long, and so 'well' (through our conversations
> on usenet) but now is the first moment I could identify
> you as a 'man' rather than simply a 'person'!
>
> I had always been very careful to refer to you as
> 'hiwa' or 'the last poster' or using other, non gender
> specific references to you, or things you wrote.
>
> Of course, it is always a good idea to not jump to
> conclusions, and refer to people generically.
> After all, it is all about *what* they say, rather
> than *who* (other people might think) they are*.
>
> Hope the OP has more luck with your code..
>
> * And as an aside, I am a (male) 'Jack Russell' Terrier
> .but don't hassle me about it, or I'll bite ya'.   ;-)
>
> --
> Andrew Thompsonhttp://www.athompson.info/andrew/
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-gui/200708/1

Yes. I hate the word 'man' but I couldn't think of the word 'person'
then. Now I regret that.

Below is an improved version of the GroupLayout test program in which
we add not only components but group of groups on the main layout
group. I think this is the powerfull feature of the new layout
manager.
-----------------------------------------------
import java.awt.*;
import javax.swing.*;

public class TestGroupLayoutZ extends JPanel {
  JButton button;
  JCheckBox check;
  JComboBox combo1, combo2;
  JLabel jLabel1, jLabel2, jLabel3;
  JSpinner spinner;

  public TestGroupLayoutZ() {
    init();
  }

  private void init() {
    jLabel1 = new JLabel("l1");
    combo1 = new JComboBox();
    jLabel2 = new JLabel("l2");
    combo2 = new JComboBox();
    jLabel3 = new JLabel("l3");
    spinner = new JSpinner();
    check = new JCheckBox("check");
    button = new JButton("bouton");

    org.jdesktop.layout.GroupLayout layout
      = new org.jdesktop.layout.GroupLayout(this);
    setLayout(layout);

    /* make group of groups that occupy the same X loc as checkbox and
     * button */
    org.jdesktop.layout.GroupLayout.ParallelGroup hsubGroup
      = layout.createParallelGroup();
 
hsubGroup.add(layout.createSequentialGroup().add(jLabel1).add(combo1)).
      add(layout.createSequentialGroup().add(jLabel2).add(combo2)).
      add(layout.createSequentialGroup().add(jLabel3).add(spinner));

    /* horizontally, only one loc, but there's a subgroup above */
    org.jdesktop.layout.GroupLayout.SequentialGroup hGroup
      = layout.createSequentialGroup();
    // use group of groups created above to place on a same X loc
    hGroup.add
 
(layout.createParallelGroup().add(check).add(hsubGroup).add(button));
    layout.setHorizontalGroup(hGroup);

    /* vertically, mix of one loc and two locs */
    org.jdesktop.layout.GroupLayout.SequentialGroup vGroup
      = layout.createSequentialGroup();
    vGroup.add(layout.createSequentialGroup().add(check)).  // one loc
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).
          add(jLabel1).add(combo1)). // two locs
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).
          add(jLabel2).add(combo2)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).
          add(jLabel3).add(spinner)).
 
add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).
          add(button)); // again one loc
    layout.setVerticalGroup(vGroup);
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      public void run() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setContentPane(new TestGroupLayoutZ());
        f.pack();
        f.setVisible(true);
      }
    });
  }
}
-----------------------------------------------

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2259 — Re: GroupLayout problem,

From"Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this>
Date2011-04-27 15:38 +0000
SubjectRe: GroupLayout problem,
Message-ID<46c3f791$0$27389$ba4acef3@news.orange.fr>
In reply to#2240
  To: comp.lang.java.gui
The lib is https://swing-layout.dev.java.net/ . I thought it was common 
enough, sorry.

The 2 example you gave changes a lot of things from what i posted. The 
margin are removed, the spinner and the combo are way too big...

I'm gonna try to extract what is needed just to have the button left 
aligned. I hope it can be done.

Thanks for your help

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2260 — Re: GroupLayout problem,

From"Kaiser S." <kaiser.s.@THRWHITE.remove-dii-this>
Date2011-04-27 15:38 +0000
SubjectRe: GroupLayout problem,
Message-ID<46c3f907$0$27400$ba4acef3@news.orange.fr>
In reply to#2259
  To: comp.lang.java.gui
It was a bad parenthesis !!!!!!!!!!!!!!!!


		GroupLayout layout = new GroupLayout(this);
		this.setLayout(layout);
		
		// vertical
		
		SequentialGroup gh1 = layout.createSequentialGroup()
		.add(jLabel1)
		.addPreferredGap(LayoutStyle.RELATED)
		.add(combo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 
GroupLayout.PREFERRED_SIZE);
		
		SequentialGroup gh2 = layout.createSequentialGroup()
		.add(jLabel2)
		.addPreferredGap(LayoutStyle.RELATED)
		.add(combo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 
GroupLayout.PREFERRED_SIZE);
		
		SequentialGroup gh3 = layout.createSequentialGroup()
		.add(jLabel3)
		.addPreferredGap(LayoutStyle.RELATED)
		.add(spinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 
GroupLayout.PREFERRED_SIZE);
		
		layout.setHorizontalGroup(
				layout.createParallelGroup(GroupLayout.LEADING)
				.add(layout.createSequentialGroup()
				.addContainerGap()
				.add(layout.createParallelGroup(GroupLayout.LEADING)
				.add(check)
				.add(gh1)
				.add(gh2)
				.add(gh3) // the closing parenthesis was here
				.add(button)) // now it is here
				.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		

:D

Thanks again

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2261 — Re: GroupLayout problem,

From"hiwa" <hiwa@THRWHITE.remove-dii-this>
Date2011-04-27 15:38 +0000
SubjectRe: GroupLayout problem,
Message-ID<1187258993.744824.9140@x40g2000prg.googlegroups.com>
In reply to#2260
  To: comp.lang.java.gui
On Aug 16, 4:13 pm, "Kaiser S." <sau...@name.invalid> wrote:
> It was a bad parenthesis !!!!!!!!!!!!!!!!
>
>                 GroupLayout layout = new GroupLayout(this);
>                 this.setLayout(layout);
>
>                 // vertical
>
>                 SequentialGroup gh1 = layout.createSequentialGroup()
>                 .add(jLabel1)
>                 .addPreferredGap(LayoutStyle.RELATED)
>                 .add(combo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
> GroupLayout.PREFERRED_SIZE);
>
>                 SequentialGroup gh2 = layout.createSequentialGroup()
>                 .add(jLabel2)
>                 .addPreferredGap(LayoutStyle.RELATED)
>                 .add(combo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
> GroupLayout.PREFERRED_SIZE);
>
>                 SequentialGroup gh3 = layout.createSequentialGroup()
>                 .add(jLabel3)
>                 .addPreferredGap(LayoutStyle.RELATED)
>                 .add(spinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
> GroupLayout.PREFERRED_SIZE);
>
>                 layout.setHorizontalGroup(
>                                 layout.createParallelGroup(GroupLayout.LEADING)
>                                 .add(layout.createSequentialGroup()
>                                 .addContainerGap()
>                                 .add(layout.createParallelGroup(GroupLayout.LEADING)
>                                 .add(check)
>                                 .add(gh1)
>                                 .add(gh2)
>                                 .add(gh3) // the closing parenthesis was here
>                                 .add(button)) // now it is here
>                                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
>                 );
>
> :D
>
> Thanks again

Anyway I felt your code was machine-generated and plus org.jdesktop
implementation of the GroupLayout is 100% aimed to machine-generation
of code being hard to read to human eyes reminding me of Lisp
nightmare.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web