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

Report as inappropriate.

mik
mik presents ...

2010/10/6

UILibrary

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

9705 views / 17 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
Your browser does not support the canvas tag.
Awwww for a second i thought that Greenfoot had added volume control to the sound class :(
mikmik

2010/10/9

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

2010/11/16

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

2011/4/27

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

2013/6/4

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; }
m_p_v_13m_p_v_13

2013/6/4

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(); } }
ivanpivanp

2013/12/12

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
A new version of this scenario was uploaded on 2018-11-02 18:40:19 UTC

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

Who likes this?

ElNo Artaphawp SPower thegreencoolerman Locomotion15 MathManiac edparrish dangjavageek