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

Report as inappropriate.

mik presents ...



MSG (Michael's Simple GUI) Toolkit

This scenario provides some reusable GUI components. To use any of these components in your own scenario, copy the class to your scenario.

If the component uses custom images (such as the switch) then the used images must also be copied. A component's class comment will state if the component relies on image files. Some components (such as Button or Checkbox) do not use image files, but draw the images directly.

For components that have an associated action (such as Button), the associated listener interface (in this case: ButtonListener) must also be copied, and the world subclass must implement that interface.

License: Classes in this scenario are put into the public domain. Feel free to reuse and modify.

Author: Michael Kolling
Version: 1.1

5701 views / 15 in the last 7 days

8 votes | 0 in the last 7 days

Tags: with-source reusable gui

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.

Awwww for a second i thought that Greenfoot had added volume control to the sound class :(


No, not yet. But that might come in the future.


I hope so :D That would make my day for many days to come ^^


Nice design! Maybe you could even do better! How? By adding Layouts as a function setLayout(javax.swing.Layout) !


mik, your switch is wired backwards ;-) /** * Check whether the switch is currently on or off. * * @returns True, if the switch is currently set to "on" (the 'up' position); false otherwise. */ public boolean isOn() { return !up; }


mik, Wouldn't you want Switch.setState() to change the image also. I made the following change locally: /** * Set this switch to on or off. * * @param on If true, set to on. Otherwise set to off. */ public void setState(boolean on) { if ( up != on ) { toggle(); } }


Hello Mik, Have you guys considered adding user input/output as native support from Greenfoot framework? I am switching my students from Scratch to Greenfoot and lack of this support from the framework makes the projects limited to pure graphics applications. I know there are scenarios/projects which provide some sort of UI but it would be best IMO to let the OS handle these elements. Thanks, Ivan

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

Who likes this?

ElNo Artaphawp SPower thegreencoolerman Locomotion15 MathManiac edparrish dangjavageek