小编Mic*_*ael的帖子

如何在 JavaFx 中向标签添加 actionListener

我正在尝试将一个 ActionListener 添加到一个标签,每当用户输入错误的密码或登录名时就会弹出。这是我的登录控制器

public class LoginController implements Initializable {

@FXML
private Label label;
@FXML
private TextField LoginField;
@FXML
private PasswordField PasswdField;
@FXML
private Button LogInButton;
@FXML
private Label IncorrectDataLabel;
//private String uri = "http://google.com";



@FXML
private void LogIn(ActionEvent event) throws IOException {
    if(LoginField.getText().equals("MKARK")&&PasswdField.getText().equals("KACZOR1"))
    {

        Parent parent = FXMLLoader.load(getClass().getResource("/fxmlFiles/MainScreen.fxml"));
        Scene MainScene = new Scene(parent);
        Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
        stage.setScene(MainScene);
        stage.show();


    }
    else
    {
        IncorrectDataLabel.setVisible(true);
        // <------------------- Here I want to bind hyperlink to a label with would open the …
Run Code Online (Sandbox Code Playgroud)

label javafx hyperlink

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

hyperlink ×1

javafx ×1

label ×1