0
A
回答
0
FlowPane
自動適合TabPane
中的所有空間。請看下面的例子!如果您增加或減少場景的寬度,您實際上可以看到它的工作原理!
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class FlowPaneExample extends Application {
@Override
public void start(Stage primaryStage) {
VBox mockCalendar = new VBox();
TabPane tabPane = new TabPane();
Tab tab = new Tab("Month");
tabPane.getTabs().add(tab);
FlowPane header = new FlowPane();
//pad the header text objects on the top and bottom
header.setPadding(new Insets(5, 0, 5, 0));
//Set the vetical and horizontal gap between text objects
header.setVgap(3);
header.setHgap(3);
//Creates a series of Text objects to file the top FlowPane
Text monDay = new Text("Mon");
monDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text tueDay = new Text("Tue");
tueDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text wedDay = new Text("Wed");
wedDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text thuDay = new Text("Thu");
thuDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text friDay = new Text("Fri");
friDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text satDay = new Text("Sat");
satDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
Text sunDay = new Text("Sun");
sunDay.setFont(Font.font("Arial", FontWeight.BOLD, 20));
//Add the Text objects as children to the FlowPane
header.getChildren().add(monDay);
header.getChildren().add(tueDay);
header.getChildren().add(wedDay);
header.getChildren().add(thuDay);
header.getChildren().add(friDay);
header.getChildren().add(satDay);
header.getChildren().add(sunDay);
FlowPane content = new FlowPane();
//pad the text objects to match the header FlowPane
content.setPadding(new Insets(5, 5, 5, 5));
//Set the vetical and horizontal gap between text objects
content.setVgap(10);
content.setHgap(25);
//Set the content of the second FlowPane using text objects created from
//the string array
for (int i = 0; i<33; i++)
{
String[] days = {" " , " " , " 1" , " 2" , " 3" ,
" 4" , " 5" , " 6" ,
" 7" , " 8" , " 9" , "10" , "11" , "12" ,
"13" , "14" , "15" , "16" , "17" , "18" ,
"19" , "20" , "21", "22" , "23" , "24" ,
"25" , "26" , "27" , "28" , "29" , "30" , "31"};
content.getChildren().add(new Text(days[i]));
}
//Add the two FlowPane objects to the VBox
mockCalendar.getChildren().add(header);
mockCalendar.getChildren().add(content);
tab.setContent(mockCalendar);
//Use the Vbox as the root node of the Scene
Scene scene = new Scene(tabPane, 280, 300);
primaryStage.setTitle("FlowPane Example Program");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
相關問題
- 1. 在javaFX中將文本區域自動調整爲tabpane
- 2. 我怎樣才能讓flowpane滾動時調整
- 3. 自動調整
- 4. jQuery - 將動畫高度自動調整爲
- 5. 自動調整UILabel
- 6. iPhone自動調整
- 7. 自動調整Html.TextBoxFor
- 8. GridSplitter自動調整
- 9. 調整表自動
- 10. 將圖像調整爲自動調整大小的柔性孩子
- 11. ImageButton將自動調整圖像
- 12. UIScrollView將不會自動調整大小
- 13. 將調整大小UITableViewCell自動調整其contentView?
- 14. UINavigationController自動調整視圖行爲
- 15. 自動調整的EditText爲Android
- 16. NSTimeZone在iPhone中自動調整爲DST
- 17. 調整python自動完成行爲
- 18. iPad的 - 自動調整爲UITableView的
- 19. 的fancybox自動調整(自動調整大小)的問題
- 20. android:textview將自己調整爲錯誤layout_width
- 21. DBS爲什麼不自動調整/調整緩衝區大小?
- 22. 如何將指令自動對焦調整爲自動對焦=「true」/「false」?
- 23. WP7將文本塊自動調整爲最大值
- 24. jquery(或CSS)將iframe自動調整爲底部?
- 25. 檢測是否將屏幕亮度調整設置爲自動
- 26. 將UINavigationB自動調整爲橫向旋轉
- 27. 將Spark TextInput擴展爲自動調整大小
- 28. 將XIB文件自動調整爲屏幕大小
- 29. JavaFX - FlowPane Autosize
- 30. FlowPane和定位