Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Labels

Started by Vexorian Dec 8, 2005 at 12:59 PM 5 replies 950+ views
Original Post
Vexorian
Vexorian
Any way to have 2 labels really close ? I tried to use setBounds(new Rectangle(stuff) ) when adding the labels to a panel that doesn't have a LayoutManager but it seriously didn't work out. Is there any way to place a control on the actual coordinates you want? Is there a way to have more than 1 line (rather 8 lines) in the same label? A little explanation: I have 5 labels, their text seems like this: Label 1 Label 2 Label 3 Label 4 Label 5 I want it to be like this: Label 1 Label 2 Label 3 Label 4 Label 5 "Closer" The actual idea is to have a game that uses just ascii characters (I know it is stupid but it is for a class project) It would be like this:

###########################
#  #O                     #
#        O      <         #
#  O                      #
###########################



Currently the separation between the labels is too big and it looks ugly. ps: It must stick to AWT;
------ XYE - A new edition of the classic Kye
cignox1
cignox1
setLayout(NULL) should remove the layout and let you specify the position and size using seBounds().
IIRC there should be also a way to put more lines in a Label, but I really don't remember what is it.
Vexorian
Vexorian
Tried NULL and now they don't even show up, there is something I am missing let me check the documentation
------ XYE - A new edition of the classic Kye
Whackjack
Whackjack
I thought that if you add a "\n" in the string, that will let you have multiple lines.
cignox1
cignox1
Quote:
Original post by Vexorian
Tried NULL and now they don't even show up, there is something I am missing let me check the documentation


If you remove the layout, then you have to set a size because otherwise it defaults to w=0, h=0 (I think) and you wont see anything.
try setBounds(0,0100,10); just after the setLayout(NULL);
Vexorian
Vexorian
Quote:
Original post by Whackjack
I thought that if you add a "\n" in the string, that will let you have multiple lines.


It shows \n as ?

Quote:


If you remove the layout, then you have to set a size because otherwise it defaults to w=0, h=0 (I think) and you wont see anything.
try setBounds(0,0100,10); just after the setLayout(NULL);


I already used setBounds

..

I decided a disabled textarea would work well enough for this case
------ XYE - A new edition of the classic Kye
cignox1
cignox1
'\n' is the how a C string represents the ASCII code for 'new line' and wont be printed. But I don't know if it works. Can you post the label initialization code?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.