Skip to content
Snippets Groups Projects
Commit 4ef9760f authored by tmp1u19's avatar tmp1u19 :octopus:
Browse files

Cell class which defines a cell in the grid of the game.

parent fb21531b
No related branches found
No related tags found
No related merge requests found
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment