Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Awt Label Newline?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chromium




PostPosted: Thu Jun 06, 2013 3:39 pm   Post subject: Awt Label Newline?

Hi im trying to output text onto a new line using an awt label. I though that using \n would work but it doesnt.
Ive searched but i cant seem to find anything. Anyone know how? Thanks
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Jun 06, 2013 4:14 pm   Post subject: RE:Awt Label Newline?

Have you tried googling an obvious phrase like "java awt label multiline"? I ask because the first result that Google returns for that query is a StackOverflow question that has your answer.

Hint: HTML.
chromium




PostPosted: Thu Jun 06, 2013 4:28 pm   Post subject: Re: RE:Awt Label Newline?

DemonWasp @ Thu Jun 06, 2013 4:14 pm wrote:
Have you tried googling an obvious phrase like "java awt label multiline"? I ask because the first result that Google returns for that query is a StackOverflow question that has your answer.

Hint: HTML.


But that is for JLabels. Awt labels dont accept HTML.
Nathan4102




PostPosted: Thu Jun 06, 2013 4:42 pm   Post subject: Re: RE:Awt Label Newline?

chromium @ Thu Jun 06, 2013 5:28 pm wrote:


But that is for JLabels. Awt labels dont accept HTML.


Quote:
Have you tried googling an obvious phrase like "java awt label multiline"?


The first link doesn't help, so you ask us to do it for you? Try the second link.
DemonWasp




PostPosted: Thu Jun 06, 2013 5:13 pm   Post subject: RE:Awt Label Newline?

Huh, didn't notice that. Looks like AWT labels don't support multiline (the API states this in the first line).

You'll have to either use more than one Label (and carefully lay things out), implement that functionality yourself, or find an existing implementation.

Or use Swing, which supports this by default. Why are you using AWT rather than Swing anyway?
chromium




PostPosted: Thu Jun 06, 2013 5:38 pm   Post subject: Re: RE:Awt Label Newline?

DemonWasp @ Thu Jun 06, 2013 5:13 pm wrote:
Huh, didn't notice that. Looks like AWT labels don't support multiline (the API states this in the first line).

You'll have to either use more than one Label (and carefully lay things out), implement that functionality yourself, or find an existing implementation.

Or use Swing, which supports this by default. Why are you using AWT rather than Swing anyway?


Ok i guess ill just create another label.

Im using awt because at the time i started my project that was the only ui stuff that my teacher had taught us.
I tried to convert the program to swing, but a lot of issues popped up and it was too much of a pain to go through and fix each thing.
I really wish i used swing from the beginning though. Especially because of how easy it is to assign an image to a button. (my game is whack a mole)
Its actually quite sad what it has come down to. Instead of having a mole picture appear on the buttons, ive had to settle with button.setLabel (":D").
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: