【发布时间】:2017-07-05 05:52:31
【问题描述】:
我正在尝试切换到 javafx 而不是 swing,但尝试找到执行确切任务的方法有点困难。
- 我正在尝试让按钮宽度填充整个场景,并在您调整场景大小时进行相应调整。
- 在文本区域和按钮周围设置一个小的空白边框。
-
获取读取纯文本文件并替换当前文本区域(不追加)的方法。
package gui; mport javafx.application.Application; mport javafx.scene.Scene; mport javafx.scene.control.Button; mport javafx.stage.Stage; mport javafx.scene.layout.*; mport javafx.scene.control.TextArea; public class Main extends Application{ @Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("TextArea Experiment 1"); TextArea textArea = new TextArea(); // Which TextArea method would I call to set a plain // text file into the text area ? BorderPane border = new BorderPane(); border.setCenter(textArea); //border.setBorder(new EmptyBorder(10,10,10,10)); // Is there a method like this in JavaFx ? GridPane grid = new GridPane(); border.setBottom(grid); double screensize = border.getMaxWidth(); Button option1 = new Button("Button 1"); Button option2 = new Button("Button 2"); Button option3 = new Button("Button 3"); // how can I get the buttons to be max scene size and //adjust dynamically to scene dimensions ? option1.setMaxSize(Double.MAX_VALUE,Double.MAX_VALUE); //option1.setPrefWidth(Double.MAX_VALUE); System.out.println(screensize); grid.add(option1, 0,1); grid.add(option2,0,2); grid.add(option3,0,3); Scene scene = new Scene(border, 200, 100); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { Application.launch(args); } }
【问题讨论】:
-
你在一个线程中问了太多问题。尝试每个线程问一个问题。
标签: button javafx textarea border