Results 1 to 3 of 3
  1. #1
    joseche is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Unhappy Problem with margins/spacing

    Hi folks,

    I am trying to build a JToolBar menu with some Icons, but I just can't find the way to add the JButtons without having them align properly, my problem is that the spacing between the TOP of the JToolBar and the TOP of the JButton is huge, so I've trying with:

    JToolBar MenuArbol= new JToolBar("TEST",SwingConstants.HORIZONTAL);
    MenuArbol.setPreferredSize(new Dimension(150, 25));
    MenuArbol.setLayout(new FlowLayout());
    MenuArbol.setMargin(new Insets(1,1,1,1));
    MenuArbol.setBorder(new EmptyBorder(1,1,1,1));
    MenuArbol.setAlignmentY(TOP_ALIGNMENT);

    JButton clusview= new JButton("TOP");
    clusview.setBorder(new EmptyBorder(1, 1, 1, 1));
    clusview.setMargin(new Insets(1, 1, 1, 1));
    clusview.setAlignmentY(0.1f);
    clusview.setVerticalAlignment(SwingConstants.TOP);
    clusview.addActionListener(this);
    MenuArbol.add(clusview);

    Nothing seems to work, is there any other method or property to set that I am missing ?

    thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You might want to create a small compilable program that we can all compile and run that does nothing but creates a toolbar and demonstrates your problem. Again, this program should be as short as possible and should have absolutely no functionality other than to demonstrate this problem. If you do this, I almost guarantee you'll get quick help. Best of luck.

  3. #3
    joseche is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    I nailed it already !, it was the FlowLayout making the components have the spacing, I removed the FlowLayout and all worked as supposed.

    Thanks !

Similar Threads

  1. Spacing buttons on a panel
    By 2o2 in forum New To Java
    Replies: 8
    Last Post: 10-20-2008, 11:44 AM
  2. Help with spacing in java
    By barney in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 09:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •