0

The textarea-class in JavaFX should give me the option to add rows and columns, but the way I tried didn't work:

    TextArea ta = new TextArea();
    ta.setPrefRowCount(100);
    ta.setPrefColumnCount(100);

I'm searching for columns/rows like in Microsoft Excel, inclusive the gridines.

.setGridLinesVisible(true);

doesn't work for this Type.

2 Answers 2

2

For use case similiar to Excel you're actually looking for TableView. Every table cell can contain anything, even another window so it is very flexible.

If you want grid lines on top of TextArea, but want to keep the standard TextArea behavior, you will have to combine the TextArea and TableView in a StackPane. You will just have to clear the table's background using CSS. However, matching the row and column sizes with the text will need some additional code.

Apologies for my English.

Sign up to request clarification or add additional context in comments.

1 Comment

TableView was the solution! Thanks! :)
1

colums/rows like in Microsoft Excel, inclusive the gridines

TableView as recommended in Michael's answer is likely the right basic solution for.

There are some 3rd party controls you might consider which add some basic spreadsheet like functionality to the base JavaFX TableView control:

  1. SpreadsheetView from the ControlsFX project.
  2. TiwulFX from Panemu.

1 Comment

I think this would also be ok, but I don't want to use 3rd party libraries at the point where I'm staying. But thanks for your answer! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.