在javafx中添加BorderedTitle窗格

时间:2014-04-02 08:36:10

标签: javafx javafx-2

我是javafx的新手。我想在我的应用程序中添加标题边框。我已经使用了从stackoverflow上的另一个线程得到的程序,它可以独立运行..但是当我尝试在其他容器中添加这个BorderedTitledPane并在BorderedTitledPane中添加GridPane或ScrollPane时,底部边框消失了。我附加了我的codehere。从我这边可能是愚蠢的错误..但我是新的,没有得到

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.collections.*?>
<?import java.lang.*?>
<?import javafx.scene.Group?>
<?import javax.swing.JPanel?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TitledPane?>
<?import application.TitleBorder?>
<?import javafx.scene.shape.Line?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" prefHeight="500.0"  prefWidth="670.0">

    <TitledPane text="Details"  prefWidth="650.0">
                    <TitleBorder  title="Temp data for the month" >

                        <GridPane  layoutX="10.0" hgap="10" translateY="3.0" vgap="5" prefWidth="600.0" style="-fx-background-color: #BEBEBE;-fx-padding: 10 10 10 10;" >
                            <Label text="Service Code" prefWidth="100" GridPane.columnIndex="0"
                                GridPane.rowIndex="0" />
                            <Label text="ABCD"  prefWidth="100" GridPane.columnIndex="1"
                                GridPane.rowIndex="0" />
                            <Label text="XYZ" prefWidth="100" GridPane.columnIndex="2"
                                GridPane.rowIndex="0" />
                            <Label text="PQR" prefWidth="100" GridPane.columnIndex="3"
                                GridPane.rowIndex="0" />
                            <Label text="ABC" prefWidth="100" GridPane.columnIndex="4"
                                GridPane.rowIndex="0" />
                            <Label text="Total" prefWidth="100" GridPane.columnIndex="5"
                                GridPane.rowIndex="0" />

                            <ScrollPane  pannable="false"  prefHeight="100.0"  GridPane.columnSpan="6" GridPane.columnIndex="0"
                                GridPane.rowIndex="1" prefWidth="600.0" style="-fx-background-color: #BEBEBE;">

                                <GridPane hgap="10" prefWidth="600.0" prefHeight="150.0">

                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="0" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="0" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="0" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="0" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="0" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="0" />

                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="1" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="1" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="1" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="1" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="1" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="1" />

                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="2" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="2" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="2" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="2" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="2" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="2" />

                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="5" />


                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="4" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="4" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="4" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="4" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="4" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="4" />

                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="0" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="1" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="2" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="3" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="4" GridPane.rowIndex="5" />
                                    <TextField alignment="BASELINE_RIGHT" prefWidth="100"
                                        GridPane.columnIndex="5" GridPane.rowIndex="5" />


                                </GridPane>
                        </ScrollPane>

                     <Label text="Total temp data in the month to be dudected" prefWidth="380" GridPane.columnIndex="0"
                                GridPane.rowIndex="2" GridPane.columnSpan="6" />
                        <TextField alignment="BASELINE_RIGHT" prefWidth="100" translateX="-17.0"
                                        GridPane.columnIndex="5" GridPane.rowIndex="2" />   

                        </GridPane>
                    </TitleBorder>
                </TitledPane>

</AnchorPane>

和Css文件如下:

![.bordered-titled-title {
  -fx-translate-x:  8;
  -fx-translate-y: -10;
  -fx-padding: 0 0 0 4;
  -fx-background-color: #BEBEBE;
}

.bordered-titled-border {
  -fx-content-display: top;
  -fx-border-insets: 2 0 0 0;
  -fx-border-color: #000000;
  -fx-border-width: 2;
}

.bordered-titled-content {
  -fx-padding: 18 5 5 5;
}][1]

0 个答案:

没有答案