Моя Java-программа не компилируется, и я просто пытаюсь добраться до точки, где моя Java-программа запускает файл FXML и просто отображает GUI. Я не знаю, как добраться до этой точки.
Я использовал Scenebuilder для написания кода для графического интерфейса, но я не уверен, как прикрепить код проекта к коду, чтобы он отображался.
Main.java
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javax.swing.*;
public class Main extends Application {
private JTextField guess_space; // text field for user's guess
private JLabel bottom_Lab; // label for too high/too low output
private int theNumber; // The number we are trying to find
public void checkGuess() { // Method that checks Hi-Lo of guess
String guessText = guess_space.getText();
String message;
// Check the guess for too high/too low
int guess = Integer.parseInt(guessText);
// if the guess is too high
if (guess > theNumber) {
message = guess + " was too high. Guess again!";
bottom_Lab.setText(message);
}
// if the guess is too low
else if (guess < theNumber) {
message = guess + " was too low. Guess again!";
bottom_Lab.setText(message);
}
else {
message = guess + " was the correct guess. You Win!!!";
}
}
public void newGame() {
theNumber = (int)(Math.random()* 100 + 1);
}
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("GuessingGame.fxml"));
primaryStage.setTitle("Guessing Game");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
Main theGame = new Main();
theGame.newGame();
}
public static void main(String[] args) {
launch(args);
}
Controller.java
package sample;
import xxx
public class Controller {
}