Slick Forums

Discuss the Slick 2D Library
It is currently Sun Dec 17, 2017 6:17 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Help with TextArea
PostPosted: Wed Aug 14, 2013 11:10 am 
Offline
User avatar

Joined: Wed Feb 08, 2012 10:32 pm
Posts: 13
Location: Germany
Somehow my TextArea does not display any text. What am I doing wrong?

This is my code:

Code:
HTMLTextAreaModel model = new HTMLTextAreaModel();
TextArea text = new TextArea(model);
text.setSize(700, 200);
text.setPosition(50, 50);
model.setHtml("<html><body><p>Example Text</p></body></html>");
rootpane.add(text);


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Wed Aug 14, 2013 7:12 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Did you setup it's theme? Look at the examples for details.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Thu Aug 15, 2013 5:14 pm 
Offline
User avatar

Joined: Wed Feb 08, 2012 10:32 pm
Posts: 13
Location: Germany
Yes, I have:

Code:
<fontDef name="normal" filename="../fonts/CarbonBlock.fnt" default="true" color="#0014ff">
   <fontParam if="error" color="red" />
   <fontParam if="textSelection" color="white" />
</fontDef>
<theme name="textarea" ref="-defaults">
   <param name="background"><image>textarea.background</image></param>
   <param name="fonts">
      <map>
         <param name="default"><font>normal</font></param>
      </map>
   </param>
   <param name="images"><map></map></param>
</theme>


The same font is used for labels and listboxes and works fine.
I also removed the font from the font map and it generated the error message, that it could not find a font named 'default', so I'm assuming the font is loaded correctly.


I can see the background image of the TextArea, there's just no way I can get it to display my text :(
I also tried SimpleTextAreaModel, but that did not work either.


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Thu Aug 15, 2013 7:02 pm 
Offline

Joined: Tue Oct 11, 2011 7:30 pm
Posts: 32
Don't you need something like this aswell in your text area?

Code:
        <param name="font">
            <font>normal</font>
        </param>


You have a map of fonts but not specified a font to actually use


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Thu Aug 15, 2013 7:13 pm 
Offline
User avatar

Joined: Wed Feb 08, 2012 10:32 pm
Posts: 13
Location: Germany
The "-defaults" theme already includes this line.

Also, I think the TextArea selects a font from the fonts map.


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Thu Aug 15, 2013 8:11 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Yes, the TextArea uses a fonts map instead of a single font. And it will warn when a requested font could not be found.

In your code you call setSize and setPosition outside of your layout() method - this is generally not recommended / unsupported (except for special Widgets like ResizableFrame or PopupWindow).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Help with TextArea
PostPosted: Thu Aug 15, 2013 9:05 pm 
Offline
User avatar

Joined: Wed Feb 08, 2012 10:32 pm
Posts: 13
Location: Germany
I moved this code to layoutRootPane(), but it still does not work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group