我不知道为什么我会收到此错误。我已经多次检查过每一行。
com.sun.javafx.css.parser.CSSParser解析 警告:CSS错误解析文件:/ C:/Users/rmanassya/Desktop/BinaryNameV1.1/BinaryNamev1.1/BinaryName/bin/style.css:[75,0]预期的LBRACE
我的CSS
.center-text-area *.text {
-fx-text-alignment: center;
}
#top-radius{
-fx-border-radius: 50 50 0 0;
-fx-background-radius: 50 50 0 0;
}
#ipad-grey {
-fx-background-color:
linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%),
linear-gradient(#020b02, #3a3a3a),
linear-gradient(#b9b9b9 0%, #c2c2c2 20%, #afafaf 80%, #c8c8c8 100%),
linear-gradient(#f5f5f5 0%, #dbdbdb 50%, #cacaca 51%, #d7d7d7 100%);
-fx-background-insets: 0,1,4,5;
-fx-background-radius: 9,8,5,4;
-fx-padding: 15 30 15 30;
-fx-font-family: "Arial Rounded MT Bold";
-fx-font-size: 30px;
-fx-font-weight: bold;
-fx-text-fill: #333333;
-fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.2) , 1, 0.0 , 0
, 1);
margin: 100px;
-fx-pref-width: 300px;
}
#ipad-grey Text {
-fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
#shiny-orange{
-fx-background-color:
linear-gradient(#ffd65b, #e68400),
linear-gradient(#ffef84, #f2ba44),
linear-gradient(#ffea6a, #efaa22),
linear-gradient(#ffe657 0%, #f8c202 50%, #eea10b 100%),
linear-gradient(from 0% 0% to 15% 50%, rgba(255,255,255,0.9),
rgba(255,255,255,0));
-fx-background-radius: 30;
-fx-background-insets: 0,1,2,3,0;
-fx-text-fill: #333333;
-fx-font-weight: bold;
-fx-font-size: 30px;
-fx-padding: 10 20 10 20;
-fx-pref-width: 700px;
}
#shiny-orange-reset{
-fx-background-color:
linear-gradient(#ffd65b, #e68400),
linear-gradient(#ffef84, #f2ba44),
linear-gradient(#ffea6a, #efaa22),
linear-gradient(#ffe657 0%, #f8c202 50%, #eea10b 100%),
linear-gradient(from 0% 0% to 15% 50%, rgba(255,255,255,0.9),
rgba(255,255,255,0));
-fx-background-radius: 30;
-fx-background-insets: 0,1,2,3,0;
-fx-text-fill: #333333;
-fx-font-weight: bold;
-fx-font-size: 30px;
-fx-padding: 10 20 10 20;
-fx-pref-width: 300px;
}
.button-pressed:pressed{
-fx-background-color: gray;
}
#CMHlogo {
-fx-background-image: url("codinghangout_logos_green.png");
-fx-background-repeat: no-repeat;
-fx-background-size: 270 190;
-fx-background-position: top left;
}
JavaFx代码
public class Main extends Application {
public static void main1(String[] args) {
if (args.length == 0) {
try {
// re-launch the app itselft with VM option passed
Runtime.getRuntime().exec(new String[] {"java", "-
Dcom.sun.javafx.isEmbedded-true", "-Dcom.sun.javafx.touch=true", "-
Dcom.sun.javafx.virtualKeyboard=javafx", "-jar", "BinaryName1.jar"});
} catch (IOException ioe) {
ioe.printStackTrace();
}
System.exit(0);
}
// Run the main program with the VM option set
//...
//...
}
private ConversionController conversionController = new
ConversionController();
private PopupWindow keyboard;
private final Rectangle2D visualBounds =
Screen.getPrimary().getVisualBounds();
private final Rectangle2D bounds = Screen.getPrimary().getBounds();
private final double taskbarHeight = bounds.getHeight() -
visualBounds.getHeight();
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Binary Name");
Label helloLbl = new Label("Hello");
helloLbl.setAlignment(Pos.CENTER);
helloLbl.setFont(Font.font("Comic Sans MS", FontWeight.BOLD, 68));
helloLbl.setStyle("-fx-background-color: red;padding: 20px;");
helloLbl.setTextFill(Color.web("#ffffff"));
Label myNameLbl = new Label("my name is");
myNameLbl.setAlignment(Pos.CENTER);
myNameLbl.setFont(Font.font("Comic Sans MS", 48));
myNameLbl.setStyle("-fx-background-color: red;padding: 20px;");
myNameLbl.setTextFill(Color.web("#ffffff"));
VBox logoBox = new VBox(10);
logoBox.setId("CMHlogo");
logoBox.getChildren().addAll(helloLbl, myNameLbl);
logoBox.setAlignment(Pos.CENTER);
TextArea nameTxtArea = new TextArea();
nameTxtArea.setWrapText(Boolean.TRUE);
nameTxtArea.getStyleClass().add("center-text-area");
nameTxtArea.setFont(Font.font("Comic Sans MS", 28));
nameTxtArea.setStyle("padding: 40px;");
Label dummy = new Label(" ");
dummy.setStyle("-fx-background-color: red;");
dummy.setFont(Font.font("Comic Sans MS", FontWeight.BOLD, 30));
/**Button printBtn = new Button("PRINT");
printBtn.setId("ipad-grey");
printBtn.setDisable(Boolean.TRUE);*/
Button convertBtn = new Button("Check Your Answer/Revisa Tu Respuesta");
convertBtn.setId("shiny-orange");
convertBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
nameTxtArea.setText(conversionController.getBinaryName
(nameTxtArea.getText()));
convertBtn.setDisable(Boolean.TRUE);
//printBtn.setDisable(Boolean.FALSE);
nameTxtArea.requestFocus();
}
});
Button resetBtn = new Button("RESET");
resetBtn.setId("shiny-orange-reset");
resetBtn.getStyleClass().add("button-pressed");
resetBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// Reset
nameTxtArea.setText("");
convertBtn.setDisable(Boolean.FALSE);
//printBtn.setDisable(Boolean.TRUE);
nameTxtArea.requestFocus();
}
});
HBox hBox = new HBox(100);
hBox.setAlignment(Pos.CENTER);
hBox.getChildren().addAll(convertBtn); // add printBtn next to
convertBtn,
VBox vBox = new VBox(10);
vBox.setAlignment(Pos.TOP_CENTER);
vBox.getChildren().addAll(logoBox, nameTxtArea, dummy, hBox, resetBtn);
vBox.setStyle("-fx-background-color: red;margin: 20px;");
vBox.setId("top-radius");
编辑:我没有第75行。代码在第73行结束。我通过CSSlint运行它并没有看到与此相关的错误。它使用相同的代码工作正常,但现在不行。
编辑:我删除了部分CSS并运行了该程序。程序运行时应用了CSS样式。我完成了删除所有CSS代码并发生了同样的事情。它为什么这样做?如果没有CSS代码,CSS如何运行?我的JavaFX中没有任何css命令,