JavaFX:删除锚定窗格中的焦点边框
JavaFX: Remove focused border in anchor pane
我想在聚焦锚定窗格时删除红色边框。我尝试了不同的方法,例如:
#rootPane {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
或以编程方式
rootPane.setStyle("-fx-focus-color: 透明;");
我有一个带有以下 fxml 的登录屏幕:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="rootPane" prefHeight="500.0" prefWidth="350" stylesheets="@Login_neu.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.erp.ui.login.LoginController_new">
<children>
<AnchorPane fx:id="ap_title" minHeight="0.0" minWidth="0.0" prefHeight="148.0" prefWidth="350.0">
<children>
<Text id="welcome-text" layoutX="29.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Warehouse MMM Solution" wrappingWidth="270.13671875" />
<Text id="welcome-text2" layoutX="181.0" layoutY="76.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Powered by SAP" wrappingWidth="166.13671875" />
</children>
</AnchorPane>
<AnchorPane fx:id="ap_login" layoutX="-4.0" layoutY="150.0" minHeight="0.0" minWidth="0.0" prefHeight="350.0" prefWidth="350.0">
<children>
<ProgressBar fx:id="progressbar" disable="true" layoutX="75.0" layoutY="312.0" maxHeight="3.0" minHeight="3.0" prefHeight="3.0" prefWidth="200.0" visible="false" />
<Button fx:id="btn_submit" layoutX="249.0" layoutY="268.0" onAction="#handleSubmitAction" text="Sign In" AnchorPane.rightAnchor="46.0">
<opaqueInsets>
<Insets right="20.0" />
</opaqueInsets>
</Button>
<Label fx:id="lbl_username" layoutX="100.0" layoutY="38.0" text="Username:" />
<Label fx:id="lbl_plant" layoutX="100.0" layoutY="178.0" text="Plant:" />
<Label fx:id="lbl_password" layoutX="100.0" layoutY="106.0" text="Password" />
<TextField fx:id="tf_username" layoutX="100.0" layoutY="61.0" />
<PasswordField fx:id="pf_password" layoutX="100.0" layoutY="133.0" text="182832" />
<ComboBox fx:id="cb_plants" disable="true" layoutX="100.0" layoutY="205.0" prefWidth="150.0" />
</children>
</AnchorPane>
</children>
</AnchorPane>
如果我这样做
#ap_login {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
或
#rootPane {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
只有按钮有效。
Css 文件如下所示:
.root {
}
#welcome-text {
-fx-font-size: 20.0px;
-fx-fill: black;
-fx-font-weight: bold;
}
#welcome-text2 {
-fx-font-size: 14.0px;
-fx-fill: black;
-fx-font-weight: bold;
}
#ap_title {
-fx-background-color: #9dd34c;
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
#ap_login {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
我解决了这个问题。当我聚焦 window 时会出现红色边框,因为当我更改背景时我会不明显地挂钩 "Automatically pick an accent colour from my background"。我没有多想。所以,下次我一定会知道的。还是谢谢了。
我想在聚焦锚定窗格时删除红色边框。我尝试了不同的方法,例如:
#rootPane {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
或以编程方式 rootPane.setStyle("-fx-focus-color: 透明;");
我有一个带有以下 fxml 的登录屏幕:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="rootPane" prefHeight="500.0" prefWidth="350" stylesheets="@Login_neu.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.erp.ui.login.LoginController_new">
<children>
<AnchorPane fx:id="ap_title" minHeight="0.0" minWidth="0.0" prefHeight="148.0" prefWidth="350.0">
<children>
<Text id="welcome-text" layoutX="29.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Warehouse MMM Solution" wrappingWidth="270.13671875" />
<Text id="welcome-text2" layoutX="181.0" layoutY="76.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Powered by SAP" wrappingWidth="166.13671875" />
</children>
</AnchorPane>
<AnchorPane fx:id="ap_login" layoutX="-4.0" layoutY="150.0" minHeight="0.0" minWidth="0.0" prefHeight="350.0" prefWidth="350.0">
<children>
<ProgressBar fx:id="progressbar" disable="true" layoutX="75.0" layoutY="312.0" maxHeight="3.0" minHeight="3.0" prefHeight="3.0" prefWidth="200.0" visible="false" />
<Button fx:id="btn_submit" layoutX="249.0" layoutY="268.0" onAction="#handleSubmitAction" text="Sign In" AnchorPane.rightAnchor="46.0">
<opaqueInsets>
<Insets right="20.0" />
</opaqueInsets>
</Button>
<Label fx:id="lbl_username" layoutX="100.0" layoutY="38.0" text="Username:" />
<Label fx:id="lbl_plant" layoutX="100.0" layoutY="178.0" text="Plant:" />
<Label fx:id="lbl_password" layoutX="100.0" layoutY="106.0" text="Password" />
<TextField fx:id="tf_username" layoutX="100.0" layoutY="61.0" />
<PasswordField fx:id="pf_password" layoutX="100.0" layoutY="133.0" text="182832" />
<ComboBox fx:id="cb_plants" disable="true" layoutX="100.0" layoutY="205.0" prefWidth="150.0" />
</children>
</AnchorPane>
</children>
</AnchorPane>
如果我这样做
#ap_login {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
或
#rootPane {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
只有按钮有效。
Css 文件如下所示:
.root {
}
#welcome-text {
-fx-font-size: 20.0px;
-fx-fill: black;
-fx-font-weight: bold;
}
#welcome-text2 {
-fx-font-size: 14.0px;
-fx-fill: black;
-fx-font-weight: bold;
}
#ap_title {
-fx-background-color: #9dd34c;
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
#ap_login {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
我解决了这个问题。当我聚焦 window 时会出现红色边框,因为当我更改背景时我会不明显地挂钩 "Automatically pick an accent colour from my background"。我没有多想。所以,下次我一定会知道的。还是谢谢了。