JavaFXのcontrolsfxのライブラリ(http://fxexperience.com/controlsfx/)を使って、ステータスバーを表示させることはできましたが、実行させると以下のように全体に表示されます。↓
これを縦幅を細くして、下側に表示させるにはどうすればいいのでしょうか?
JAVAコードは以下の通りです。
JAVA
1 2package test1; 3 4import javafx.application.Application; 5import javafx.fxml.FXMLLoader; 6import javafx.geometry.Rectangle2D; 7import javafx.scene.Parent; 8import javafx.scene.Scene; 9import javafx.stage.Screen; 10import javafx.stage.Stage; 11import javafx.scene.control.Button; 12import org.controlsfx.control.StatusBar; 13 14 15public class Test1 extends Application { 16 17 @Override 18 public void start(Stage stage) throws Exception { 19 Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); 20 21 Scene scene = new Scene(root); 22 23 Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); 24 25 26 /* 27 ステータスバーを表示 28 */ 29 StatusBar statusBar = new StatusBar(); 30 statusBar.getRightItems().add(new Button("Info")); 31 statusBar.setProgress(.5); 32 33 /* 34 画面を最大化 35 */ 36 stage.setX(primaryScreenBounds.getMinX()); 37 stage.setY(primaryScreenBounds.getMinY()); 38 stage.setWidth(primaryScreenBounds.getWidth()); 39 stage.setHeight(primaryScreenBounds.getHeight()); 40 stage.setMaximized(true);//画面を最大化に設定 41 stage.setScene(scene); 42 Scene scene1 = new Scene(statusBar); 43 stage.setScene(scene1); 44 45 46 47 /* 48 画面を表示 49 */ 50 stage.show(); 51 } 52 53 /** 54 * @param args the command line arguments 55 */ 56 public static void main(String[] args) { 57 launch(args); 58 } 59 60} 61
FXMLコードは以下の通りです。
FXML
1<?xml version="1.0" encoding="UTF-8"?> 2 3<?import javafx.scene.control.Button?> 4<?import javafx.scene.control.Menu?> 5<?import javafx.scene.control.MenuBar?> 6<?import javafx.scene.control.MenuItem?> 7<?import javafx.scene.control.ToolBar?> 8<?import javafx.scene.image.Image?> 9<?import javafx.scene.image.ImageView?> 10<?import javafx.scene.layout.AnchorPane?> 11<?import javafx.scene.layout.BorderPane?> 12<?import javafx.scene.layout.ColumnConstraints?> 13<?import javafx.scene.layout.GridPane?> 14<?import javafx.scene.layout.RowConstraints?> 15 16 17<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="724.0" prefWidth="1072.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"> 18 <children> 19 <BorderPane layoutX="188.0" layoutY="58.0" prefHeight="400.0" prefWidth="786.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 20 <top> 21 <GridPane prefHeight="77.0" prefWidth="1072.0" BorderPane.alignment="CENTER"> 22 <columnConstraints> 23 <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 24 </columnConstraints> 25 <rowConstraints> 26 <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 27 <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 28 </rowConstraints> 29 <children> 30 <MenuBar> 31 <menus> 32 <Menu mnemonicParsing="false" text="File"> 33 <items> 34 <MenuItem mnemonicParsing="false" text="Close" /> 35 </items> 36 </Menu> 37 <Menu mnemonicParsing="false" text="Edit"> 38 <items> 39 <MenuItem mnemonicParsing="false" text="Delete" /> 40 </items> 41 </Menu> 42 <Menu mnemonicParsing="false" text="Help"> 43 <items> 44 <MenuItem mnemonicParsing="false" text="About" /> 45 </items> 46 </Menu> 47 </menus> 48 </MenuBar> 49 <ToolBar prefHeight="40.0" prefWidth="200.0" GridPane.rowIndex="1"> 50 <items> 51 <Button mnemonicParsing="false" prefHeight="31.0" prefWidth="36.0" stylesheets="@test.css"> 52 <graphic> 53 <ImageView pickOnBounds="true" preserveRatio="true"> 54 <image> 55 <Image url="@New_16x16.png" /> 56 </image> 57 </ImageView> 58 </graphic> 59 </Button> 60 </items> 61 </ToolBar> 62 </children> 63 </GridPane> 64 </top> 65 </BorderPane> 66 </children> 67</AnchorPane> 68
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/24 07:52