A.F*_*ere 6 javafx javafx-2 fxml scenebuilder
我尝试使用FXML和CSS更改app构建中的单选按钮大小.我使用的是sceneBuilder.
谢谢你的帮助 !
这是我的单选按钮的实际CSS代码:
.radio-button .radio{
-fx-border-width : 1px ;
-fx-border-color : #000 ;
-fx-background-color : white ;
-fx-background-image : null ;
-fx-border-radius : 15px ;
-fx-height : 15px ; /* Not working */
height : 5px ; /* Not working */
}
.radio-button .radio:selected{
-fx-background-color : white ;
-fx-background-image : null ;
}
.radio-button -radio:armed{
-fx-background-color : white ;
-fx-background-image : null ;
}
.radio-button -radio:determinate{
-fx-background-color : white ;
-fx-background-image : null ;
}
.radio-button -radio:indeterminate{
-fx-background-color : white ;
-fx-background-image : null ;
}
Run Code Online (Sandbox Code Playgroud)
-fx-padding: 10px;
单个填充值意味着所有填充都相同,如果指定了一组四个填充值,则它们用于区域的顶部,右侧,底部和左侧边缘.
例:
CssTest.java
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.RadioButton;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class CssTest extends Application
{
public void start(Stage stage) throws Exception
{
BorderPane root = new BorderPane();
RadioButton radio = new RadioButton("radio-text");
root.setCenter(radio);
root.getStylesheets().add(getClass().getResource("/radio.css").toExternalForm());
stage.setScene(new Scene(root));
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
Run Code Online (Sandbox Code Playgroud)
radio.css
.radio-button .radio {
-fx-border-width: 1px;
-fx-border-color: #000;
-fx-background-color: white;
-fx-background-image: null;
-fx-border-radius: 15px;
-fx-padding: 4px;
}
.radio-button .radio:selected {
-fx-background-color: white;
-fx-background-image: null;
}
.radio-button -radio:armed {
-fx-background-color: white;
-fx-background-image: null;
}
.radio-button -radio:determinate {
-fx-background-color: white;
-fx-background-image: null;
}
.radio-button -radio:indeterminate {
-fx-background-color: white;
-fx-background-image: null;
}
.radio-button .dot {
-fx-background-radius: 15px;
-fx-padding: 8px;
}
Run Code Online (Sandbox Code Playgroud)
结果

欲了解更多鼓舞人心的JavaFX的CSS主题,请win7glass.css从GreggSetzer/JavaFX的CSS-主题
| 归档时间: |
|
| 查看次数: |
14352 次 |
| 最近记录: |