这是我的应用程序
public void start(Stage primaryStage){
ControlPane ctrlPane = new ControlPane(); //extends TitledPane and customize it
LogViewPane lvPane = new LogViewPane("ChartName"); //extends TitledPane and customize it
HBox hboxCtrl = new HBox(ctrlPane);
hboxCtrl.setFillHeight(false);
HBox hboxLV = new HBox(lvPane);
hboxLV.setFillHeight(false);
VBox vbox = new VBox();
vbox.setFillWidth(false);
VBox.setMargin(hboxCtrl, new Insets(5));
VBox.setMargin(hboxLV, new Insets(0, 5, 5, 5));
vbox.getChildren().addAll(hboxCtrl, hboxLV);
ScrollPane mainScrollPanel = new ScrollPane();
mainScrollPanel.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
mainScrollPanel.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
mainScrollPanel.setFitToHeight(true);
mainScrollPanel.setFitToWidth(true);
mainScrollPanel.setContent(vbox);
Scene scene = new Scene(mainScrollPanel);
//load css
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.centerOnScreen();
primaryStage.show();
}
这是LogViewPane:
public class LogViewPane extends TitledPane{
public LogViewPane(String chartName){
super("LOG", null);
HBox hbox = new HBox();
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setPadding(new Insets(10));
TextField inputDate = new TextField();
inputDate.setMinWidth(100);
inputDate.setMaxWidth(100);
Button buttonLog = new Button("LOG");
Button buttonChart = new Button("CHART");
HBox.setMargin(inputDate, new Insets(0, 10, 0, 0));
HBox.setMargin(buttonLog, new Insets(0, 10, 0, 0));
HBox.setMargin(buttonChart, new Insets(0));
hbox.getChildren().addAll(inputDate, buttonLog, buttonChart);
this.setCollapsible(false);
this.setContent(hbox);
}
}
在缩小窗口大小之前,我的应用看起来还不错。
当我减小窗口大小时,LogViewPane的按钮会收缩。
以下是我所谈论的内容的图片:
当窗口尺寸小时,如何防止按钮收缩?
这就是我想要的: