Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Component Orientation, TOP to BOTTOM.  (Read 2327 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2007-04-30 13:26:27 »

I am using Gridlayout with 30 rows and 1 column. Thinking of using 15 rows and 2 columns instead but I want to list the first 15 to the left and the last 15 to the right


1 2
3 4

is not what I want

instead

1 16
2 17
3 18
4 19
5 20
6 21
7 22
8 23
9 24
10 25
11 26
12 27
13 28
14 29
15 30



Any way to do it?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2007-04-30 13:57:55 »

put your components in an array and feed the array in the way the GridLayout expects, and AFAIK you can't change the ordering of components

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #2 - Posted 2007-04-30 16:10:23 »

1  
2  
3  
4  
5  
6  
JPanel mainPanel = new JPanel(new GridLayout(1, 2));
JPanel leftPanel = new JPanel(new GridLayout(15, 1));
JPanel rightPanel = new JPanel(new GridLayout(15, 1));

mainPanel.add(leftPanel);
mainPanel.add(rightPanel);


Don't forget that you can layer layout managers.  Anytime you are creating a complex layout and are unsure about how to proceed, just make a drawing of the layout and use vertical and horizontal lines to cut the diagram into layout managers.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2007-04-30 19:35:12 »

Indeed, until we get a decent layout manager, that doesn't require any tools.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline fletchergames

Senior Member





« Reply #4 - Posted 2007-05-01 17:35:29 »

If the Components are the same size and there are the same number of Components in each column, you could probably just make a horizontal box of 2 vertical boxes.

But to use GridLayout, you can just add the components in a different order like someone already said.
Offline JAW

Senior Member


Medals: 2



« Reply #5 - Posted 2007-05-04 12:44:16 »

You can always use setLayout(null) and setBounds(x,y,w,h) on all Components. It can be a pain to do, but has highest precision and flexibility in the end. Using a visual editor might be an idea.

-JAW
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #6 - Posted 2007-05-04 15:44:44 »

Learn to use LayoutManagers effectively and you will be happier for it.

Offline fletchergames

Senior Member





« Reply #7 - Posted 2007-05-04 18:03:53 »

You can always use setLayout(null) and setBounds(x,y,w,h) on all Components. It can be a pain to do, but has highest precision and flexibility in the end. Using a visual editor might be an idea.

-JAW

There's an alternative to null layouts at http://www.swingwiki.org/workaround:fixed_position_layout .  I wrote my own slightly different version that uses Rectangles.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (73 views)
2014-09-10 06:39:09

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (44 views)
2014-09-07 01:13:42

Longarmx (27 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!