forked from j62/ctbrec
1
0
Fork 0

Make layout grow horizontally

This commit is contained in:
0xboobface 2020-07-05 15:35:17 +02:00
parent 6117d24e13
commit faf3d469f0
2 changed files with 17 additions and 20 deletions

View File

@ -59,7 +59,7 @@ import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
public class ActionSettingsPanel extends Pane {
public class ActionSettingsPanel extends GridPane {
private static final Logger LOG = LoggerFactory.getLogger(ActionSettingsPanel.class);
private ListView<EventHandlerConfiguration> actionTable;
@ -89,22 +89,21 @@ public class ActionSettingsPanel extends Pane {
}
private void createGui() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
getChildren().add(grid);
setHgap(10);
setVgap(10);
setPadding(new Insets(20, 10, 10, 10));
Label headline = new Label("Events & Actions");
headline.getStyleClass().add("settings-group-label");
grid.add(headline, 0, 0);
add(headline, 0, 0);
actionTable = createActionTable();
ScrollPane scrollPane = new ScrollPane(actionTable);
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
scrollPane.setStyle("-fx-background-color: -fx-background");
grid.add(scrollPane, 0, 1);
add(scrollPane, 0, 1);
GridPane.setHgrow(scrollPane, Priority.ALWAYS);
Button add = new Button("Add");
add.setOnAction(this::add);
@ -113,7 +112,7 @@ public class ActionSettingsPanel extends Pane {
delete.setDisable(true);
HBox buttons = new HBox(5, add, delete);
buttons.setStyle("-fx-background-color: -fx-background"); // workaround so that the buttons don't shrink
grid.add(buttons, 0, 2);
add(buttons, 0, 2);
actionTable.getSelectionModel().getSelectedItems().addListener((ListChangeListener<EventHandlerConfiguration>) change -> delete.setDisable(change.getList().isEmpty()));
}

View File

@ -35,10 +35,10 @@ import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.stage.FileChooser;
public class IgnoreList extends Pane {
public class IgnoreList extends GridPane {
private static final Logger LOG = LoggerFactory.getLogger(IgnoreList.class);
@ -53,14 +53,13 @@ public class IgnoreList extends Pane {
}
private void createGui() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
setHgap(10);
setVgap(10);
setPadding(new Insets(20, 10, 10, 10));
Label headline = new Label("Ignore List");
headline.getStyleClass().add("settings-group-label");
grid.add(headline, 0, 0);
add(headline, 0, 0);
ignoreListView = new ListView<>();
ignoreListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
@ -69,7 +68,8 @@ public class IgnoreList extends Pane {
removeSelectedModels();
}
});
grid.add(ignoreListView, 0, 1);
add(ignoreListView, 0, 1);
GridPane.setHgrow(ignoreListView, Priority.ALWAYS);
Button remove = new Button("Remove");
remove.setOnAction(evt -> removeSelectedModels());
@ -78,10 +78,8 @@ public class IgnoreList extends Pane {
Button importIgnoreList = new Button("Import");
importIgnoreList.setOnAction(e -> importIgnoreList());
HBox buttons = new HBox(10, remove, exportIgnoreList, importIgnoreList);
grid.add(buttons, 0, 2);
add(buttons, 0, 2);
buttons.setStyle("-fx-background-color: -fx-background"); // workaround so that the buttons don't shrink
getChildren().add(grid);
}
private void removeSelectedModels() {