diff --git a/Cell.java b/Cell.java new file mode 100644 index 0000000000000000000000000000000000000000..0757b12057d6c4224db2b377cc8bbaf264f6c797 --- /dev/null +++ b/Cell.java @@ -0,0 +1,63 @@ +import javafx.geometry.Pos; +import javafx.scene.control.TextField; +import javafx.scene.layout.*; +import javafx.scene.control.Label; +import javafx.scene.text.Font; + +public class Cell extends Pane { + + private Label label = new Label(); + private TextField input; + private int i; + private int j; + + public Cell(int n, int i, int j) { + + this.i = i; + this.j = j; + + input = new TextField(); + setPrefSize(400/n, 400/n); + + setStyle("- fx-background-color: transparent;"); + + input.setStyle("-fx-text-box-border: transparent; -fx-background-color: transparent;"); + input.setAlignment(Pos.CENTER); + input.setFont(Font.font(35)); + input.setPrefWidth(400/n); + input.setPrefHeight(400/n); + + getChildren().add(input); + } + + public void setLabel(String label) { + + this.label.setText(label); + this.label.setAlignment(Pos.TOP_LEFT); + getChildren().add(this.label); + } + + public String getLabel() { + return label.getText(); + } + + public TextField getTextField() { + return input; + } + + public boolean isNumeric(String text) { + try { + Integer.parseInt(text); + return true; + } catch(Exception e) { + return false; + } + } + public int getRow() { + return i; + } + + public int getColumn() { + return j; + } +}