通过JavaFX GUI发送消息

时间:2017-05-17 02:17:32

标签: java javafx

大家好,所以我正在开发一个能够通过我的API客户端使用Nexmo向某个号码发送消息的应用程序。在我用来发送文本消息的UsersController中,当我运行它时说错误:

Caused by: javafx.fxml.LoadException: 
/C:/Users/man/workspace/DatabaseProgramm/target/classes/fxml/User.fxml:9

Caused by: java.lang.ClassNotFoundException: UsersController

我将UsersController类定义如下:

//Necessary imports 
public class UsersController implements Initializable
{
    @FXML 
    public static TextField txtTo;
    @FXML 
    public static TextField txtMessage;
    @FXML 
    public Button btnSend;

    @Override
    public void initialize(URL location, ResourceBundle resources)
    {
        try
        {
            String getTo = txtTo.getText();
            String getMsg = txtMessage.getText();
            AuthMethod auth = new TokenAuthMethod("api_key", "api_id");
            NexmoClient client = new NexmoClient(auth);
            TextMessage text = new TextMessage("12013514464", getTo, getMsg);

            btnSend = new Button();


        }catch(Exception e){}
    }

    @FXML 
    private void sendMessage() throws IOException, NexmoClientException
    {
        AuthMethod auth = new TokenAuthMethod("api_key", "api_id");
        NexmoClient client = new NexmoClient(auth);

        TextMessage text = new TextMessage("12013514464", "+12063760671", "YIKES");
        SmsSubmissionResult[] responses = client.getSmsClient().submitMessage(text);
        for(SmsSubmissionResult response : responses)
        {
            System.out.println(response);
        }

    }

}

在Users.xml文件中,我将控制器设置为Users控制器:

<AnchorPane prefHeight="401.0" prefWidth="506.0" style="&#10;" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="UsersController">

为什么java说上面的行有错误,并且它声明没有类UsersController?对此的帮助太棒了!

0 个答案:

没有答案