11 Replies - 1354 Views - Last Post: 08 November 2011 - 02:57 PM Rate Topic: -----

#1 StuckInJava  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 143
  • Joined: 11-November 10

Swing GUI Distance Between components

Posted 08 November 2011 - 12:51 PM

Hi there, does one know how I could go about altering the distance between components using the TableLayout?

I am currently having to put in dummy rows and columns filled with panels etc of the required height to do so.

Thanks :online2long:
Is This A Good Question/Topic? 0
  • +

Replies To: Swing GUI Distance Between components

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 01:16 PM

Should be posted in the Android forum

If Android has a setBorder() method for the Component you can set a
BorderFactory.createEmptyBorder(2, 2, 2, 2);
to all your components

This post has been edited by pbl: 08 November 2011 - 01:30 PM
Reason for edit:: Android correctly spelled

Was This Post Helpful? 0
  • +
  • -

#3 StuckInJava  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 143
  • Joined: 11-November 10

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 01:17 PM

What do you mean Android?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 01:29 PM

Oups... is there a TableLayout in pure Java ? Is this a new feature of JRE 1.7 ?
Just looked in the API didn't see it.
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10561
  • View blog
  • Posts: 39,073
  • Joined: 27-December 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 01:32 PM

See the documentation. The layout alignments seem to be what you will want to tweak.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 01:42 PM

I would like to see the import statements at the beginning of your code to find out where you get it

Anyhow, if it is in standard API, which the link ported by Mac is not, you can add an emptyBorder to your JPanels
Was This Post Helpful? 0
  • +
  • -

#7 StuckInJava  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 143
  • Joined: 11-November 10

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:15 PM

Its from here:

http://java.sun.com/...es/tablelayout/

I still can't work it out.

You have rows and columns.

So I have two rows.

I want row1 to be separated more from row2 any idea on how to do it?

You just add to a row like somepanel.add(somecompoenent(new TableLayoutConstraints(1,1)) where (1,1) is a cell.
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:21 PM

Your lucky, I don't see TableLayoutConstraint neither
What are your import statements ?
Was This Post Helpful? 0
  • +
  • -

#9 StuckInJava  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 143
  • Joined: 11-November 10

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:24 PM

import layout.TableLayout;
import layout.TableLayoutConstraints;
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:36 PM

OK, so it is not in the sandard API and you download it from somewhere (may be at Sun)
Makes more sense, I am not coming insane.
Was This Post Helpful? 0
  • +
  • -

#11 StuckInJava  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 143
  • Joined: 11-November 10

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:40 PM

So I take it nobody knows how to help? Haha its such an obscure layout but its the best I have ever used bar this one niggle.
Was This Post Helpful? 0
  • +
  • -

#12 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Swing GUI Distance Between components

Posted 08 November 2011 - 02:57 PM

The sources are in the .jar

In the class itself (2236 lines) there is no provision in the 2 constructors to put a gap between components as the GridLayout does.
No other method provide that facility. Actully many methods are to satify: implements java.awt.LayoutManager2

In the source of the Constraint (210 lines) there is only provisions for alignment T,B,L,R nothing about gap

So your best bets are:
- a small row in heigh with noting in it
- an emptyBorder around your panels
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1