2017-11-10 6 views
0

したがって、テスト目的のために現時点でスタイル内のスタイルシートを1つだけ持っています。javafxシーンビルダに適用されるスタイルシート(アプリケーションを実行するときには適用されません)

CSSコード:

.minimizeBtn{ 
-fx-background-color: rgba(0,0,0,1); 
} 

ボタンのIDを設定します。これはステージのコントローラにあります。 FXMLで

public void initialize(URL url, ResourceBundle rb) { 
    handler = new DbHandlers();  

    minimizeBtn1.setId("minimizeBtn"); 

マイボタン:

<Button fx:id="minimizeBtn1" layoutX="520.0" mnemonicParsing="false" 

prefHeight="25.0" prefWidth="12.0" styleClass="minimizeBtn" text="Button" /> 
      <Button layoutX="548.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="maximizeBtn" text="Button" /> 
      <Button layoutX="574.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="closeBtn" text="Button" /> 

私のFXMLファイルの残りの部分:

<AnchorPane prefHeight="450.0" prefWidth="600.0" style="-fx-background-color: #2A7FFF;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="bownhrmain1.pages.LoginScreenController"> 
    <children> 
     <AnchorPane prefHeight="450.0" prefWidth="600.0" style="-fx-background-color: #2A7FFF;"> 
     <children> 
      <Label layoutX="335.0" layoutY="144.0" text="Inventory Systems" textFill="WHITE"> 
       <font> 
        <Font size="8.0" /> 
       </font> 
      </Label> 
      <ImageView fitHeight="150.0" fitWidth="200.0" layoutX="200.0" layoutY="65.0" pickOnBounds="true" preserveRatio="true"> 
       <image> 
        <Image url="@../images/benx_logo.png" /> 
       </image> 
      </ImageView> 
      <Hyperlink layoutX="250.0" layoutY="368.0" text="Forgot Password?" textFill="WHITE" underline="true" /> 
      <JFXButton fx:id="loginBtn" buttonType="RAISED" layoutX="190.0" layoutY="302.0" prefHeight="51.0" prefWidth="221.0" ripplerFill="#2980b9" style="-fx-background-color: #1E5D87;" text="Login" textFill="WHITE" /> 
      <JFXPasswordField fx:id="passwordField" focusColor="#1e5d87" labelFloat="true" layoutX="190.0" layoutY="237.0" prefHeight="34.0" prefWidth="221.0" promptText="Password..." unFocusColor="WHITE" /> 
      <JFXTextField id="text-field" fx:id="usernameField" focusColor="#1e5d87" labelFloat="true" layoutX="190.0" layoutY="176.0" prefHeight="32.0" prefWidth="221.0" promptText="Username/Email..." unFocusColor="WHITE" /> 
      <ImageView fitHeight="20.0" fitWidth="19.0" layoutX="522.0" layoutY="5.0" pickOnBounds="true"> 
       <image> 
        <Image url="@../images/minimize.png" /> 
       </image> 
      </ImageView> 
      <ImageView fitHeight="11.0" fitWidth="12.0" layoutX="554.0" layoutY="9.0" pickOnBounds="true"> 
       <image> 
        <Image url="@../images/expand-button.png" /> 
       </image> 
      </ImageView> 
      <ImageView fitHeight="11.0" fitWidth="11.0" layoutX="581.0" layoutY="9.0" pickOnBounds="true"> 
       <image> 
        <Image url="@../images/closeWindow.png" /> 
       </image> 
      </ImageView> 
      <Button fx:id="minimizeBtn1" layoutX="520.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="minimizeBtn" text="Button" /> 
      <Button layoutX="548.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="maximizeBtn" text="Button" /> 
      <Button layoutX="574.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="closeBtn" text="Button" /> 
     </children> 
     </AnchorPane> 
    </children> 
</AnchorPane> 

私は両方の設定を試してみましたので、私はボタンのstyleClassのを持っている理由は、クラス名とIDでcssここで

はJavaFXのシーンビルダでの作業CSSの画像です:

CSS Applying in scene builder. ここでは、プログラムを実行するときに適用するために失敗することのimageeです:

Not applying

答えて

0

だから、これに対する答えあなたの開始機能に以下を追加することです:

scene.getStylesheets().add(getClass().getResource("pathtostylesheet").toExternalForm()); 
関連する問題