2017-05-17 25 views
-1

TabPaneにアイコンとテキストを追加したい場合、私のケースのタブは画像のように左側に配置されます。私は、次のことを達成したい:TabPaneのアイコンとテキスト

  1. タブ内のテキストが回転しなければならないし、水平に整列されなければならない

  2. 私は一緒にアイコンを追加したい(それは図に見えるものを好きではありません。)テキストと一緒に。私は図bのmspaintで編集した後、最終画面を表示しています。

図a。 enter image description here


図b。 enter image description here

編集:

私はHow to add an icon to the Tab control in FXML?に続くが、私はイチジクBにしたいが、それは図Cのように見えるように私はアイコンを取得しておりません。私は以下のスタイルを追加しようとしましたが、変更はありません:

.tab-pane { 
    -fx-tab-min-width:120px; 
    -fx-tab-max-width:120px; 
    -fx-tab-min-height:50px; 
    -fx-tab-max-height:50px; 
} 

図c。 enter image description here

+0

OK ..go。 **質問があるとき私達に戻ってください。** –

+0

@AndrewThompson私は推測する質問を掲載しました。 __ – Vishrant

+1

*「私はポニーが欲しい」*は質問ではありませんが、「どこでポニーを入手できますか?」*または「あなたは私にポニーを渡しますか?私のポニー? "**は**の質問です。 *あなたの質問が*「*仕様のコーディング方法?」*の場合は広すぎます。あなたの質問は***に戻ってきますか?*** –

答えて

0

はあなたのプロジェクトにアイデアを適用し、好きなだけTabを作成することができ、このをご検討ください:

UPDATE

サイズを変更する場合は

import javafx.application.Application; 
import javafx.geometry.Pos; 
import javafx.geometry.Side; 
import javafx.scene.Scene; 
import javafx.scene.control.Label; 
import javafx.scene.control.Tab; 
import javafx.scene.control.TabPane; 
import javafx.scene.image.Image; 
import javafx.scene.image.ImageView; 
import javafx.scene.layout.Pane; 
import javafx.scene.layout.VBox; 
import javafx.stage.Stage; 

public class TabPaneExample extends Application{ 

    @Override 
    public void start(Stage ps) throws Exception { 

     VBox content = new VBox(); // create a VBox to act like a graphic content for the Tab 

     /////////////////////////////////////////// 
     Label label = new Label("Text"); 
     label.setAlignment(Pos.BOTTOM_CENTER); 

     ImageView icon = new ImageView(new Image("file:C:\\Users\\Yahya\\Desktop\\icon.png")); // for example 
     icon.setFitWidth(25); icon.setFitHeight(25); // your preference 
     /////////////////////////////////////////// 

     // add the components to the VBox 
     // You can set the Margins between the children ..etc 
     content.getChildren().addAll(icon, label); 
     //content.setAlignment(Pos.BOTTOM_CENTER); 

     Tab tab = new Tab();// create a Tab object and set the Graphic 
     tab.setGraphic(content); 

     // create TabPane, set side to left 
     // all other values need manipulation (i.e. up to your preference) 
     TabPane tabPane = new TabPane(tab); 
     tabPane.setSide(Side.LEFT); 

     // just simple root to see the result 
     Pane root = new Pane(); 
     root.getChildren().add(tabPane); 

     Scene scene = new Scene(root, 300,300); 
     ps.setScene(scene); 
     ps.show(); 
    } 

    public static void main(String[] args){ 
     launch(); 
    } 

} 

タブをクリックします(値は、たとえば次のとおりです)。

tabPane.setTabMinHeight(50); 
tabPane.setTabMaxHeight(50); 
tabPane.setTabMinWidth(100); 
tabPane.setTabMaxWidth(100); 
そのため

結果

enter image description here

+0

@VishrantあなたのIDEにコードをコピーして貼り付けてみてください。 – Yahya

+0

ありがとう、コード 'icon.setFitWidth(25);のサイズを' 25'から '55'に増やしています。 icon.setFitHeight(25); 'タブのサイズが増えていません。 – Vishrant

+0

と私はサイズ55のための切り刻まれたイメージとテキストを得ています。 – Vishrant

関連する問題