Задача Суматор с графичен интерфейс!
Здравейте колеги. Опитвам да направя задачата Суматор. Инсталирал съм и Scene Builder. Всичко работи. Следвам стъпките описани в примера. Изчертал съм полето, текстовите полета, бутона и тн. След стартиране ми дава грешка, че не намира Sample.Main при положение, че всичко е там и при писане на кода нямам индикации за грешки. Моля за насоки. Предварително благодаря.
Грешката при стартиране:
"C:\Program Files\Java\jdk1.8.0_151\bin\java" "-javaagent:F:\Programing\Нова папка\IntelliJ IDEA Community Edition 2017.3.2\lib\idea_rt.jar=50974:F:\Programing\Нова папка\IntelliJ IDEA Community Edition 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_151\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\access-bridge.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\rt.jar" sample.Main
Error: Could not find or load main class sample.Main
Process finished with exit code 1
сорс на Sample:
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.RowConstraints?> <GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.121" fx:controller="sample.Controller"> <columnConstraints> <ColumnConstraints /> </columnConstraints> <rowConstraints> <RowConstraints /> </rowConstraints> <children> <AnchorPane prefHeight="200.0" prefWidth="200.0"> <children> <TextField layoutX="5.0" layoutY="14.0" prefHeight="25.0" prefWidth="54.0" /> <TextField layoutX="77.0" layoutY="14.0" prefHeight="25.0" prefWidth="54.0" /> <TextField layoutX="164.0" layoutY="14.0" prefHeight="25.0" prefWidth="54.0" /> <Label layoutX="65.0" layoutY="18.0" prefHeight="17.0" prefWidth="16.0" text="+" /> <Label layoutX="143.0" layoutY="18.0" text="=" /> <Button layoutX="78.0" layoutY="61.0" mnemonicParsing="false" text="Button" /> </children> </AnchorPane> </children> </GridPane>
Сорс на Main:
package sample; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); primaryStage.setTitle("Sumator"); primaryStage.setScene(new Scene(root)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }