GUI Klassen Version 0.1
Unvollständige Variante der Klassen für Button und Label, zusätzlich noch die Oberklasse GUI_Interface.pull/20/head
parent
40b1752ddc
commit
a1e62f825e
@ -1,19 +1,36 @@
|
|||||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
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)
|
* @author Felix Stupp
|
||||||
* @version (a version number or a date)
|
* @version 10.05.2016
|
||||||
*/
|
*/
|
||||||
public class GUI_Interface extends Actor
|
public class GUI_Interface extends Actor
|
||||||
{
|
{
|
||||||
/**
|
protected int sx = 1;
|
||||||
* Act - do whatever the GUI_Interface wants to do. This method is called whenever
|
protected int sy = 1;
|
||||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
|
||||||
*/
|
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()
|
public void act()
|
||||||
{
|
{
|
||||||
// Add your action code here.
|
// Add your action code here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void redraw();
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 173 B |
Binary file not shown.
After Width: | Height: | Size: 164 B |
Loading…
Reference in New Issue