Issue
In Lazarus, there are 2 different kinds of tab elements (cf. Free Pascal docs):
TPageControl
TPageControl
is a multi-page component that provides a container to hold a variety of controls per page.
TTabControl
It is a tabbed container component which looks identical to a TPageControl. However, there is a fundamental difference because the control always shows the same page whichever tab is selected. In fact, it containts only a single page. The idea behind this concept is illustrated best by an editor or viewer for text files: When the TabControl contains a TMemo then the individual tabs refer to the files loaded into the memo; whenever the active tab changes another file is loaded into the (same) memo.
In this sense, JavaFX TabPane
s are quite similar to TPageControl
s, but I rather want to replicate a TTabControl
. I know I could in fact programmatically create a new Tab()
, but I want to visually design it in SceneBuilder.
Is there maybe a way to load a separate .fxml
file into a new Tab()
element which is then added to the TabPane
? (And how could I then access a tab's children?)
Solution
I chose the easiest approach: Implementing a head-less TabPane
to detect when the user switches between tabs. The elements that appear to the user as the “tab content” are actually placed outside the TabPane
, and their content is dynamically changed whenever the tab is switched.
Answered By - Pixelcode
Answer Checked By - Mary Flores (JavaFixing Volunteer)