Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2006

Tip: Looking for answers? Try searching our database.

BoxLayout, strunt, rigidarea

Thread view: 
doc. Zenobiusz Furman - 26 Sep 2006 09:49 GMT
Hello!

I've got a problem. Please look at the code below. When I use rigidarea to
spearate buttons, no matter how large is the frame, buttons are separated
properly. But when I use vertical and horizontal struts vertical space
between buttons is changing along with the frame size. What is the reason?
Thanks for any help.

import java.awt.*;
import javax.swing.*;

public class klasa {
   public static void main(String[] args) {
       Ramka r = new Ramka();
       r.setSize(200,200);
       r.pack();
       r.setVisible(true);
   }
}

class Ramka extends JFrame {
   public Ramka() {
       Container c = this.getContentPane();
       Box L1 = Box.createHorizontalBox();
       Box L2 = Box.createHorizontalBox();
       Box L = Box.createVerticalBox();
       L1.add(new JButton("test1"));
       //L1.add(Box.createRigidArea(new Dimension(5,0)));
       L1.add(Box.createHorizontalStrut(10));
       L1.add(new JButton("test2"));
       L1.setAlignmentX(Component.LEFT_ALIGNMENT);        
       L2.add(new JButton("test3"));
       //L2.add(Box.createRigidArea(new Dimension(5,0)));
       L2.add(Box.createHorizontalStrut(10));
       L2.add(new JButton("test4"));
       L2.setAlignmentX(Component.LEFT_ALIGNMENT);
       L.add(L1);
       //L.add(Box.createRigidArea(new Dimension(0,5)));
       L.add(Box.createVerticalStrut(10));
       L.add(L2);
       c.add(L);
   }
}

--
M.
Bart Cremers - 26 Sep 2006 09:56 GMT
> Hello!
>
[quoted text clipped - 8 lines]
> --
> M.

Struts have unlimited maximum heights or widths (for horizontal and
vertical struts, respectively). This means that if you use a horizontal
box within a vertical box, for example, the horizontal box can
sometimes become too tall. For this reason, it's  recommend that you
use rigid areas instead of struts.

Regards,

Bart


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.