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

Report as inappropriate.

bourne presents ...


GUI Components

Originally uploaded around November 2010.

Reusable GUI components.

What’s the big new thing?
- TextBox: Selecting Text, and Copy/Cut/Paste abilities on clipboard.
- Windows and Containers (Find examples from the Menu in the top left corner).


Note: No subclass of GUI_Component should appear in World's paint order:

15244 views / 29 in the last 7 days

17 votes | 0 in the last 7 days

Tags: mouse demo menu reusable gui textbox label button bourne palette

This scenario is a member of: Reusable actors & support classes

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 Fri Jan 31 21:21:45 UTC 2014 A couple small fixes to the TextBox. ** The select Color is no longer set permanently as Yellow, but now uses GUI_Component selectColor - influenced by the static setDefaultColors method, and can be changed via the inherited setSelectColor(Color) method. ** Using the setText(String) method will reset the scroll to the "top", was a noticeable bug when having scrolled down some text, then using the setText method with a sufficiently large String
A new version of this scenario was uploaded on Mon Mar 10 19:22:17 UTC 2014 GUI_Component now has a protected method redraw() which is called whenever one of its set color or font methods are invoked. This method is used for those GUI_Components that avoid redrawing every act cycle. Overwrite it to make use of it. The Container class now listens for if its components have resized, needing to redistribute them. Included the Spacer and ImageHolder classes. A number of other improvements.
A new version of this scenario was uploaded on Mon Apr 28 19:18:04 UTC 2014 * TextBox: double/triple click to select "word" or line. Small fixes to FontWindow. * Improvements to ListBox. ListBox only redraws when needed. ListBox has better border. Some small improvements to GUI_Component. * Improvement to DropDownList. Additional fix on Window close on lose focus bug. * Button and Window now have better border, no longer single line. CheckBoxLabel enable/disable feature. Improvements to Window. Window bug fix where if the Window is set to close when lose focus, it closed if one of its components were clicked on and not gaining focus before Window realizes it no longer has focus.
A new version of this scenario was uploaded on Mon Apr 28 21:52:52 UTC 2014 TextBox focusable enable/disable feature. Fix where select by dragging would deselect when finished.


its not running :(


Bourne, I'm trying to get this running on GF3.1. Please contact me via a reply when you get this.


In case anyone is interested, I have ported this to work under version 3.1. (Suspect it will work up to 3.5.x) It's shelf life is limited as GF moves toward FX, but these are very good examples for creating GUI component. Also included are conversion utilities as adapters to go from GF Color/Font <==> awt Color/Fonts. Even if you can't run them - the code is worth looking at. Well done Borne!


Hi MrBradley, I am interested in the new version of the code and it would be great if you could send me the updated version, Thanks!


I have the updated version, but I'm not sure how to get it to you. Are you in Greenroom?


MrBradley, I think it's probably best to just upload it on your account. Just make sure to credit Bourne. He hasn't been active in a very long time

See all comments

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

Who likes this?

Nosson1459 ElNo Topdeck1 Pointifix MrHam Kartoffelbrot JetLennit Zamoht Gevater_Tod4711 MatheMagician SPower plsurveyor FlyingRabidUnicornPig Builderboy2005 Reflection Upupzealot birdy