Whenever i create a css file either by web->css or by javafx project i get the same error
Multiple markers at this line
- Syntax error on token "Invalid Character", interface expected
- Syntax error, insert "InterfaceBody" to complete CompilationUnit
i searched for the solutions but they are generally like create a new css file by web->css but that didn't help me. i further researched and i found that there is no output file for css in bin.Now i don't know what to do.Can anyone help me? here is my code(eclipse Neon):
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
System.out.println("aaaa");
Parent root=FXMLLoader.load(getClass().getResource("/application/Main.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setTitle("pvrock");
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
application.css
#label{
-fx-font-size:30px;
}
Main.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="300" prefWidth="400" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.60" fx:controller="application.MainController">
<children>
<Button fx:id="btn1" layoutX="169.0" layoutY="198.0" mnemonicParsing="false" onAction="#f1" prefHeight="23.0" prefWidth="62.0" text="Click me">
<font>
<Font size="10.0" />
</font>
</Button>
<Label fx:id="label" layoutX="146.0" layoutY="112.0" prefHeight="78.0" prefWidth="120.0" />
</children>
</AnchorPane>
MainController.java
package application;
import java.util.Random;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
public class MainController {
@FXML
private Label label;
public void f1(ActionEvent event){
Random rand=new Random();
int num=rand.nextInt(50)+1;
System.out.println(num);
label.setText(Integer.toString(num));
}
}
screenshot of errors: Compilation error