0

I've got a SpringLayout that I need to transpose.

Basically, when you create a SpringLayout it fills out the panel by columns, so that if you have

JPanel temp = new JPanel()
retCase2.add(label = new JLabel("A"));
retCase2.add(label = new JLabel("B"));
retCase2.add(label = new JLabel("C"));
retCase2.add(label = new JLabel("D"));

Utils.makeCompactGrid(retCase2,
2, 2, //rows, cols
1, 1,        //initX, initY
10, 10);  

The result is a table that looks like this:

A B
C D

However, I want

A C
B D

Does anyone know how to do this?

oliholz
  • 7,447
  • 2
  • 43
  • 82
Keshava Murthy
  • 119
  • 1
  • 2
  • 12
  • 1
    Beside first adding label C and afterwards add label B ? – Robin Mar 04 '13 at 14:21
  • Yep. Each row is being read in from an array, which means that if I can transpose it, I'll only need one for loop. Otherwise, I'll need 84 for loops (that's the number of rows I actually have). It's not an urgent question of anything. Just the kind of question that feels like it should have an easy solution. – Keshava Murthy Mar 04 '13 at 14:24

1 Answers1

0

Just switch the order of the "b" and "c"