2014-11-15 87 views
6

在JavaFX的場景生成器有一個文本字段在庫搜索:JavaFX的搜索文本框

enter image description here

這是一個默認的控制(如果讓我無法找到它)還是他們根本風格的文本字段?
我試過尋找場景生成器的源代碼,但是找不到它。

+0

我也有興趣。你有沒有找到任何例子? –

+0

有沒有示例代碼或教程? – Zcon

回答

0

我們可以讓我們自己的工具欄like this

<ToolBar prefHeight="40.0" prefWidth="349.0" > 
     <items> 
      <Button fx:id="buttonCloseSearch" styleClass="buttonSearchClose"> 
       <graphic> 
        <FontAwesomeIconView styleClass="buttonSearchCloseIcon" /> 
       </graphic> 
      </Button> 
      <CustomTextField styleClass="searchField"> 
       <left> 
        <Label styleClass="searchBoxLabel"> 
         <graphic> 
          <FontAwesomeIconView styleClass="searchBoxLabelIcon" /> 
         </graphic> 
        </Label> 
       </left> 
      </CustomTextField> 
      <Button fx:id="buttonUpSearch" styleClass="buttonUpSearch"> 
       <graphic> 
        <FontAwesomeIconView styleClass="buttonSearchUpIcon" /> 
       </graphic> 
      </Button> 
      <Button fx:id="buttonDownSearch" styleClass="buttonDownSearch"> 
       <graphic> 
        <FontAwesomeIconView styleClass="buttonSearchDownIcon" /> 
       </graphic> 
      </Button> 
     <Label text="1 of 2 matchs" /> 
     </items> 
    </ToolBar> 

.buttonSearchCloseIcon { 
 
    -glyph-size: 15; 
 
    -glyph-name: CLOSE; 
 
} 
 

 
.buttonSearchUpIcon { 
 
    -glyph-size: 15; 
 
    -glyph-name: CARET_UP; 
 
} 
 

 
.buttonSearchDownIcon { 
 
    -glyph-size: 15; 
 
    -glyph-name: CARET_DOWN; 
 
} 
 

 
.buttonSearchClose, .buttonUpSearch, .buttonDownSearch { 
 
    -fx-background-color: transparent; 
 
    -fx-background-insets: 0; 
 
} 
 

 
.searchBoxLabel { 
 
    -fx-padding: 0 2 0 7; 
 
} 
 

 
.searchBoxLabelIcon { 
 
    -glyph-size: 13; 
 
    -glyph-name: SEARCH; 
 
}