diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItem.java index 3c660da0b..d59aab680 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItem.java @@ -18,8 +18,8 @@ package org.jackhuang.hmcl.ui.account; import javafx.beans.property.*; +import javafx.scene.control.RadioButton; import javafx.scene.control.Skin; -import javafx.scene.control.ToggleButton; import javafx.scene.image.Image; import org.jackhuang.hmcl.auth.Account; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount; @@ -32,7 +32,7 @@ import org.jackhuang.hmcl.task.Schedulers; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class AccountListItem extends ToggleButton { +public class AccountListItem extends RadioButton { private final Account account; private final StringProperty title = new SimpleStringProperty(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java index 954f4da88..b4723bff2 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AccountListItemSkin.java @@ -26,7 +26,6 @@ import javafx.scene.control.SkinBase; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; -import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -41,23 +40,23 @@ public class AccountListItemSkin extends SkinBase { BorderPane root = new BorderPane(); - JFXRadioButton chkSelected = new JFXRadioButton(); + JFXRadioButton chkSelected = new JFXRadioButton() { + @Override + public void fire() { + skinnable.fire(); + } + }; BorderPane.setAlignment(chkSelected, Pos.CENTER); - chkSelected.selectedProperty().bindBidirectional(skinnable.selectedProperty()); + chkSelected.selectedProperty().bind(skinnable.selectedProperty()); root.setLeft(chkSelected); HBox center = new HBox(); center.setSpacing(8); center.setAlignment(Pos.CENTER_LEFT); - StackPane imageViewContainer = new StackPane(); - FXUtils.setLimitWidth(imageViewContainer, 32); - FXUtils.setLimitHeight(imageViewContainer, 32); - ImageView imageView = new ImageView(); FXUtils.limitSize(imageView, 32, 32); imageView.imageProperty().bind(skinnable.imageProperty()); - imageViewContainer.getChildren().setAll(imageView); TwoLineListItem item = new TwoLineListItem(); BorderPane.setAlignment(item, Pos.CENTER); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java index 838aa3e85..e4ae28d2f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItem.java @@ -19,13 +19,13 @@ package org.jackhuang.hmcl.ui.profile; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import javafx.scene.control.RadioButton; import javafx.scene.control.Skin; -import javafx.scene.control.ToggleButton; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profiles; -public class ProfileListItem extends ToggleButton { +public class ProfileListItem extends RadioButton { private final Profile profile; private final StringProperty title = new SimpleStringProperty(); private final StringProperty subtitle = new SimpleStringProperty(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java index 2a8a668a9..704cc57ce 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfileListItemSkin.java @@ -26,7 +26,6 @@ import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; -import javafx.scene.layout.StackPane; import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.SVG; @@ -39,23 +38,23 @@ public class ProfileListItemSkin extends SkinBase { BorderPane root = new BorderPane(); - JFXRadioButton chkSelected = new JFXRadioButton(); + JFXRadioButton chkSelected = new JFXRadioButton() { + @Override + public void fire() { + skinnable.fire(); + } + }; BorderPane.setAlignment(chkSelected, Pos.CENTER); - chkSelected.selectedProperty().bindBidirectional(skinnable.selectedProperty()); + chkSelected.selectedProperty().bind(skinnable.selectedProperty()); root.setLeft(chkSelected); HBox center = new HBox(); center.setSpacing(8); center.setAlignment(Pos.CENTER_LEFT); - StackPane imageViewContainer = new StackPane(); - FXUtils.setLimitWidth(imageViewContainer, 32); - FXUtils.setLimitHeight(imageViewContainer, 32); - ImageView imageView = new ImageView(); FXUtils.limitSize(imageView, 32, 32); imageView.imageProperty().set(new Image("/assets/img/craft_table.png")); - imageViewContainer.getChildren().setAll(imageView); TwoLineListItem item = new TwoLineListItem(); BorderPane.setAlignment(item, Pos.CENTER);