There is a code, a web page parser, the information in the console is in text format (not in the form of html code), and I want this information to appear in the textField when I press a button.
- And what's the problem? That does not work? - Bakhuss
- @Bakhuss I have a method in which all the code of the parser, can I somehow implement it? - Danil S
- If you are given an exhaustive answer, mark it as accepted - Alexander Semprony Grakh
|
1 answer
The TextField class has a setText(текст) method that allows you to set text . You should also prevent text input using the setEditable(false) method setEditable(false)
String text = // Текст с структурой "class Person{\n"+ " private int age;\n"+ " private String name;\n" + "\n"+ " public Person(int age, String name) {\n"+ " this.age = age;\n"+ " this.name = name;\n"+ " }\n"+ "}"; Button setText = new Button("Установить текст"); setText.setOnAction(event -> textField.setText(text)); PS Here the text in textfield text will not be structured. To fix this problem, use TextArea , which has the same methods.
- And if there is a method in which the entire code of the parser, you can use it here? - Danil S
- oneMake the method that returns a String, and use textField.setText (method ()); But the information will not be structured. - Bakhuss
- @Bakhuss understood, thanks, but can I structure it somehow? - Danil S
- @Bakhuss the problem here is that nothing is issued when you press a button, although if you just enter text (for example
textField.setText("abc");), everything works - Danil S
|