Add Widgets

This commit is contained in:
code-witch 2019-07-20 19:53:57 -06:00
parent 76f93b4450
commit aed790b857
3 changed files with 87 additions and 0 deletions

View 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() +
'}';
}
}

View 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() +
'}';
}
}

View 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() +
'}';
}
}