4 import java.util.ResourceBundle;
6 import fi.jyu.mit.fxgui.StringGrid;
7 import javafx.fxml.FXML;
8 import javafx.fxml.Initializable;
9 import javafx.scene.control.TableView;
10 import javafx.scene.control.TextArea;
23 @FXML
private StringGrid<?>
grid;
24 @FXML
private TextArea
area;
29 String
s =
grid.getRivit();
31 grid.set(
"kissa", 1, 1);
42 public void initialize(URL location, ResourceBundle resources) {
43 grid.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
46 grid.setOnGridEdit( (
t,obj,
s,
r,c) -> {
48 area.setText(
"'" +
s +
"' " +
t.getRowNr() +
" " +
t.getColumnNr());
56 grid.setOnGridLiveEdit( (
t,obj,
s,
r,c,tf) -> {
57 area.setText(
"'" +
s +
"' " +
r +
" " + c);
60 if (
s.length() > 0 ) Integer.parseInt(
s);
61 }
catch (Exception e1) {
62 tf.setStyle(
"-fx-background-color: red");
72 grid.setStyleClass(
"virhe,sininen", 1, 1);
73 grid.setStyleClass(
"s1", 0, 0);
74 grid.setStyleClass(
"s2", 1, 0);
75 grid.setStyleClass(
"s3", 2, 0);
79 grid.setOnMouseClicked( e -> {
80 int r =
grid.getRowNr();
81 int c =
grid.getColumnNr();
82 if ( r < 0 || c < 0 ) {
grid.refresh();
return; }
83 if ( e.getClickCount() == 2)
86 grid.setStyleClass(null, r, c);
90 grid.setColumnSortOrderNumber(1);
91 grid.setColumnWidth(1, 50);