This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

danpost
danpost presents ...

2014/8/13

TextImage Support Class

See scenario for description.
Click the big green 'Open in Greenfoot' button on right to download or view in greenfoot.
Copy the TextImage.JAVA file from the project folder to your 'Greenfoot/lib/greenfoot/common' folder to allow easy addition into your scenarios using the 'Edit>Import class...' option from the menubar.

CONTROLS:
- click buttons to view source code for the class
- use 'up'/'down' arrows or drag handle on vertical scroll-bar to scroll text
- press 'x' or 'escape' to exit source code viewing

Update 8/13/2014 (1):
* added 'getText' method
* added 'TextImage(String, Font)' constructor
Update 8/13/2014 (2) -- non support class changes:
* simplified some code
* added buttons for source text viewing utilizing the TextImage class
Update 8/14/2014 (1):
* added 'cloned' method
Update 8/14/2014 (2 to 4) -- non support class changes:
* added examples of using environment fonts
Update 8/20/2014:
* added font list with related methods
Update 8/22/2014:
* added default value changing methods

3659 views / 35 in the last 7 days

2 votes | 0 in the last 7 days

Tags: demo with-source danpost support source-text text-image fonts

This scenario is a member of: Support Classes by danpost


open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

A new version of this scenario was uploaded on Sat Aug 23 03:27:34 UTC 2014
DalvengyrDalvengyr

2014/12/4

This is just perfect. Anyway, if I have a custom font downloaded from somewhere, how can use that font for a text? Where should I put it (what folder)? Or user should install that font first?
danpostdanpost

2014/12/4

@Dalvengyr, I spent some time looking for a scenario a know had a 'True type font' file in a 'fonts' folder within the scenario folder. It also had a FontLoader class with it. I was hoping to share that with you, but was having trouble finding that scenario on the site (it may have been removed).
vessaliuzzvessaliuzz

2015/7/1

private void createCounters() { boardLabel = new Text("BOARD " + board); addObject (boardLabel, 670, 120); tryLabel = new Text("Nyawa: " + tries); addObject (tryLabel, 670, 150); rollsLabel = new Text("Kesempatan : " + rolls); addObject (rollsLabel, 670, 200); scoreLabel = new Text("Score: " + score + " "); addObject (scoreLabel, 670, 230); } i tried to change Text into TextImage, but error. so what should i do, n what should i write on the Board class to make it bold
A new version of this scenario was uploaded on 2017-01-22 09:22:54 UTC Fixed some constructorss missing default values.
Nosson1459Nosson1459

2017/2/16

With the listFonts() method in only shows the last 45 fonts that I have. I made my own method in the class which saves the fonts to a text file and it shows ALL my fonts.
Nosson1459Nosson1459

2017/2/16

I just saw "NOTE: DO NOT MODIFY THIS CLASS -- except for the five static 'default' fields in the modifiable section below fields.". But I technically could edit it, just maybe before I do too much testing I should copy it into the Greenfoot folder mentioned above (I also just saw that).
Nosson1459Nosson1459

2017/2/16

"Copy the TextImage.JAVA file from the project folder to your 'Greenfoot/lib/greenfoot/common' folder to allow easy addition into your scenarios using the 'Edit>Import class...' option from the menubar." Why not the CLASS file, that way it will be there but you won't see it in the Greenfoot sidebar? (But I guess then it might not show up in the import class list, I don't know much about it.)
danpostdanpost

2017/2/16

As far as the number of fonts showing up -- you probably have the terminal set to limited output. On the terminal frame menubar, go to 'options>Unlimited buffering'.
Nosson1459Nosson1459

2017/2/17

Thanks for the help.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Nosson1459 Dalvengyr