JavaFX css样式不起作用 - 未知属性+未找到资源

时间:2017-03-19 04:32:45

标签: java css javafx

我收到以下代码的警告“未知属性”,位于我的css / styles.css文件中:

.root {
    -fx-background-color: #000000;
}

我的JRE系统库中有jfxrt.jar,否则JavaFX会正常工作。

当我运行程序时,我试图将其应用到的视图上根本不显示自定义样式。

以下内容位于视图文件中:

Scene scene = new Scene(pane);
scene.getStylesheets().add("css/styles.css");
stage.setScene(scene);

编辑:

我在控制台中收到以下警告:

  

警告:找不到资源“css / styles.css”。

css文件的路径为:View/css/styles.css

登录视图的路径为View/LoginView.java

1 个答案:

答案 0 :(得分:1)

我明白了。我只需要改变

void identifyActionToPerform(int recognizeIncommingDataCode)
{
  switch (recognizeIncommingDataCode)
  {
    case 1:    //incomming phone call
    findIncommingNumber();
    processPhoneCall();
    if(reportsOnOffSetting)
    {
       if(checkRelayState())
        {
          sendStateReport();    //send state report
        }
        else sendErrorReport(); 
    }
    break;
    case 2:
    findIncommingNumber();    
    opperateRelays();   //opperate relay without state report except in case of error sendErrorReport
    if(reportsOnOffSetting==2)
    {
       if(!checkRelayState())
        {
          sendErrorReport();
        } 
    }
    break;
    case 3:
    findIncommingNumber();
    opperateRelays();    //opperate relay with state report
    sendStateReport();
    break;
    case 4:
    findIncommingNumber();    
    sendStateReport();    //send state report
    break;  
    case 5:
    findIncommingNumber();       
    sendSimReport();      //send sim report
    break;
    case 6: 
    findReportsOnOffAndStoteInEEPROM();      //turn reports on or off and save selection in eeprom     
    break;
    case 7: 
    findIncommingNumber();
    saveDefaultNumber();      //save default number to send state reports in eeprom 
    break;
//    case 8: 
//   // renewBalance();
//    break;
    case 9: 
    activateSMSChoice();
    break;

    default:    //irrelevant incomming sms
    break;      
  } 
}

void case3(void)
{

    findIncommingNumber();
    opperateRelays();    //opperate relay with state report
    sendStateReport();

}