Slick Forums
http://slick.ninjacave.com/forum/

Help with TextArea
http://slick.ninjacave.com/forum/viewtopic.php?f=18&t=6672
Page 1 of 1

Author:  Green Lightning [ Wed Aug 14, 2013 11:10 am ]
Post subject:  Help with TextArea

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);

Author:  MatthiasM [ Wed Aug 14, 2013 7:12 pm ]
Post subject:  Re: Help with TextArea

Did you setup it's theme? Look at the examples for details.

Author:  Green Lightning [ Thu Aug 15, 2013 5:14 pm ]
Post subject:  Re: Help with TextArea

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.

Author:  abcdef [ Thu Aug 15, 2013 7:02 pm ]
Post subject:  Re: Help with TextArea

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

Author:  Green Lightning [ Thu Aug 15, 2013 7:13 pm ]
Post subject:  Re: Help with TextArea

The "-defaults" theme already includes this line.

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

Author:  MatthiasM [ Thu Aug 15, 2013 8:11 pm ]
Post subject:  Re: Help with TextArea

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).

Author:  Green Lightning [ Thu Aug 15, 2013 9:05 pm ]
Post subject:  Re: Help with TextArea

I moved this code to layoutRootPane(), but it still does not work.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/