-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unvollständige Variante der Klassen für Button und Label, zusätzlich noch die Oberklasse GUI_Interface.
- Loading branch information
1 parent
40b1752
commit a1e62f8
Showing
6 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,7 @@ | |
* @version 26.04.2016 | ||
*/ | ||
public interface ButtonEvent { | ||
|
||
public void buttonClicked(Button obj); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) | ||
|
||
/** | ||
* Write a description of class GUI_Interface here. | ||
* Oberklasse für sämtliche GUI Objekte, wie Labels und Buttons | ||
* | ||
* @author (your name) | ||
* @version (a version number or a date) | ||
* @author Felix Stupp | ||
* @version 10.05.2016 | ||
*/ | ||
public class GUI_Interface extends Actor | ||
{ | ||
/** | ||
* Act - do whatever the GUI_Interface wants to do. This method is called whenever | ||
* the 'Act' or 'Run' button gets pressed in the environment. | ||
*/ | ||
protected int sx = 1; | ||
protected int sy = 1; | ||
|
||
public int getWidth() { | ||
return sx; | ||
} | ||
|
||
public int getHeight() { | ||
return sy; | ||
} | ||
|
||
public void setSize(int w, int h) { | ||
if(w < 0 || h < 0) { | ||
return; | ||
} | ||
sx = w; | ||
sy = h; | ||
} | ||
|
||
public void act() | ||
{ | ||
// Add your action code here. | ||
} | ||
} | ||
|
||
public abstract void redraw(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) | ||
import System.awt.Color; | ||
|
||
/** | ||
* Zeigt einen Text an. | ||
* | ||
* @author Felix Stupp | ||
* @version 10.05.2016 | ||
*/ | ||
public class Label extends GUI_Interface { | ||
|
||
Color foreC = Color.WHITE | ||
Color backC = Color.BLACK | ||
int textSize = 1; | ||
String text = ""; | ||
|
||
private void redraw() { | ||
GreenfootImage tI = new GreenfootImage(text,textSize,foreC,backC); | ||
setImage(tI); | ||
} | ||
|
||
public int getTextSize() { | ||
return textSize; | ||
} | ||
|
||
public void setTextSize(int s) { | ||
if(textSize != s && s > 0) { | ||
textSize = s; | ||
redraw(); | ||
} | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void setText(String s) { | ||
if(text != s) { | ||
text = s; | ||
redraw(); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.