CSSを用いたコントロールサイズの設定
背景色を設定するには「-fx-pref-width」「-fx-pref-height」を使用します。
-
-fx-pref-width [ コントロール幅を指定 ] -fx-pref-height [ コントロール高さを指定 ]
各種コントロールのsetStyleメソッドで「-fx-background-color:green;-fx-pref-width:100;-fx-pref-height:100;」を設定した実行結果を以下に示します。(実行結果をわかりやすくするために、背景をgreenに設定しています)
-
setStyle( "-fx-background-color:green;-fx-pref-width:100;-fx-pref-height:100;" )
実行例
Label
![](image/CSS_Label007.png)
Button
![](image/CSS_Button007.png)
TextField
TextFieldの横幅は「-fx-pref-width」出来ないようです。TextField横幅は「-fx-max-width」を使用してください。
![](image/CSS_TextField007.png)
TextArea
TextAreaの横幅は「-fx-pref-width」出来ないようです。TextArea横幅は「-fx-max-width」を使用してください。
![](image/CSS_TextArea007.png)
CheckBox
![](image/CSS_CheckBox007.png)
RadioButton
![](image/CSS_RadioButton007.png)
ChoiceBox
![](image/CSS_ChoiceBox007.png)
ListView
ListViewの横幅は「-fx-pref-width」出来ないようです。ListView横幅は「-fx-max-width」を使用してください。
![](image/CSS_ListView007.png)
ComboBox
![](image/CSS_ComboBox007.png)
Slider
Sliderの横幅は「-fx-pref-width」出来ないようです。Slider横幅は「-fx-max-width」を使用してください。
![](image/CSS_Slider007.png)
Progress
![](image/CSS_ProgressBar007.png)
ToolBar
ToolBarの横幅は「-fx-pref-width」出来ないようです。ToolBar横幅は「-fx-max-width」を使用してください。
![](image/CSS_ToolBar007.png)
TreeView
TreeViewの横幅は「-fx-pref-width」出来ないようです。TreeView横幅は「-fx-max-width」を使用してください。
![](image/CSS_TreeView007.png)
TreeTableView
TreeTableViewの横幅は「-fx-pref-width」出来ないようです。TreeTableView横幅は「-fx-max-width」を使用してください。
![](image/CSS_TreeTableView007.png)
![](http://www12.a8.net/0.gif?a8mat=1TV743+7K35S2+249K+BWGDT)