我有一个简单的按钮,我想点击并打开一个新场景,但我在另一个类中创建了新场景,但它不起作用,也没有显示我的错误。 这是我的Controller类
public class Controller
{
public TextField txtUsername;
public TextField txtEmail;
public TextField txtPass;
public TextField txtPhone;
public Button btnLogin;
}
public void buttonClicked()
{
Chattingform chattingform = new Chattingform ();
}
这是我的Chattingform类
public class Chattingform extends Application
{
@Override
public void start (Stage primaryStage) throws Exception {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Chattingform.fxml"));
try {
Parent root = fxmlLoader.load();
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOpacity(1);
stage.setTitle("Exchat");
stage.setScene(new Scene (root, 450, 450));
stage.showAndWait();
}catch ( IOException io )
{
JOptionPane.showMessageDialog (null, "Could not open ");
}
}
答案 0 :(得分:0)
从我的经验来看,所有JavaFX控制器都有:
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}