dev #1
17
src/fetch/widgets/EmptyWidget.java
Normal file
17
src/fetch/widgets/EmptyWidget.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package fetch.widgets;
|
||||
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
public class EmptyWidget extends Widget<StackPane> {
|
||||
|
||||
public EmptyWidget(int x, int y) {
|
||||
super(x, y, new StackPane());
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmptyWidget{" +
|
||||
"x=" + getX() +
|
||||
", y=" + getY() +
|
||||
'}';
|
||||
}
|
||||
}
|
20
src/fetch/widgets/TerminalWidget.java
Normal file
20
src/fetch/widgets/TerminalWidget.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package fetch.widgets;
|
||||
|
||||
|
||||
import javafx.scene.control.TextArea;
|
||||
|
||||
public class TerminalWidget extends Widget<TextArea> {
|
||||
|
||||
public TerminalWidget(int x,int y) {
|
||||
super(x,y, new TextArea());
|
||||
getHost().setEditable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TerminalWidget{" +
|
||||
"x=" + getX() +
|
||||
", y=" + getY() +
|
||||
'}';
|
||||
}
|
||||
}
|
50
src/fetch/widgets/Widget.java
Normal file
50
src/fetch/widgets/Widget.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package fetch.widgets;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
|
||||
public abstract class Widget<T extends Node> extends StackPane {
|
||||
private int x, y;
|
||||
private T host; // i wanted to use parent, but that's taken by the StackPane already
|
||||
|
||||
public Widget(int x,int y, T host) {
|
||||
setX(x);
|
||||
setY(y);
|
||||
setHost(host);
|
||||
|
||||
}
|
||||
|
||||
protected void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
protected void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public T getHost(){
|
||||
return host;
|
||||
}
|
||||
|
||||
protected void setHost(T host){
|
||||
this.host = host;
|
||||
this.getChildren().add(getHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Widget{" +
|
||||
"x=" + getX() +
|
||||
", y=" + getY() +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user