JavaFx remove item from TilePane
What I am trying to do is have a button with three lines of text on it.
The first line is always present. The second and third line are created as TilePane objects with three elements in them. What I am trying to do is optionally remove either the end two elements of the second and third row or alternatively the middle item depending on a configuration parameter.
What I have tried is the following:
firstRow.getChildren().addAll(leftFront, leftCentre, leftBack);
secondRow = new TilePane();
secondRow.getChildren().addAll(rightFront, rightCentre, rightBack);
leftCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
firstRow.getChildren().remove(leftBack);
firstRow.getChildren().remove(leftFront);
} else {
firstRow.getChildren().remove(leftCentre);
}
});
leftCentre.visibleProperty().bind(labelProp);
rightCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
secondRow.getChildren().remove(rightBack);
secondRow.getChildren().remove(rightFront);
} else {
secondRow.getChildren().remove(rightCentre);
}
});
rightCentre.visibleProperty().bind(labelProp);
Where the elements with left and right named items are the ones I want to remove or keep depending on the SimpleBooleanProperty labelProp
. If I set labelProp
to false the four outer elements appear. However if I set the labelProp
to true only the top line of the three appear.
So what I am doing wrong?
layout javafx-8
add a comment |
What I am trying to do is have a button with three lines of text on it.
The first line is always present. The second and third line are created as TilePane objects with three elements in them. What I am trying to do is optionally remove either the end two elements of the second and third row or alternatively the middle item depending on a configuration parameter.
What I have tried is the following:
firstRow.getChildren().addAll(leftFront, leftCentre, leftBack);
secondRow = new TilePane();
secondRow.getChildren().addAll(rightFront, rightCentre, rightBack);
leftCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
firstRow.getChildren().remove(leftBack);
firstRow.getChildren().remove(leftFront);
} else {
firstRow.getChildren().remove(leftCentre);
}
});
leftCentre.visibleProperty().bind(labelProp);
rightCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
secondRow.getChildren().remove(rightBack);
secondRow.getChildren().remove(rightFront);
} else {
secondRow.getChildren().remove(rightCentre);
}
});
rightCentre.visibleProperty().bind(labelProp);
Where the elements with left and right named items are the ones I want to remove or keep depending on the SimpleBooleanProperty labelProp
. If I set labelProp
to false the four outer elements appear. However if I set the labelProp
to true only the top line of the three appear.
So what I am doing wrong?
layout javafx-8
add a comment |
What I am trying to do is have a button with three lines of text on it.
The first line is always present. The second and third line are created as TilePane objects with three elements in them. What I am trying to do is optionally remove either the end two elements of the second and third row or alternatively the middle item depending on a configuration parameter.
What I have tried is the following:
firstRow.getChildren().addAll(leftFront, leftCentre, leftBack);
secondRow = new TilePane();
secondRow.getChildren().addAll(rightFront, rightCentre, rightBack);
leftCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
firstRow.getChildren().remove(leftBack);
firstRow.getChildren().remove(leftFront);
} else {
firstRow.getChildren().remove(leftCentre);
}
});
leftCentre.visibleProperty().bind(labelProp);
rightCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
secondRow.getChildren().remove(rightBack);
secondRow.getChildren().remove(rightFront);
} else {
secondRow.getChildren().remove(rightCentre);
}
});
rightCentre.visibleProperty().bind(labelProp);
Where the elements with left and right named items are the ones I want to remove or keep depending on the SimpleBooleanProperty labelProp
. If I set labelProp
to false the four outer elements appear. However if I set the labelProp
to true only the top line of the three appear.
So what I am doing wrong?
layout javafx-8
What I am trying to do is have a button with three lines of text on it.
The first line is always present. The second and third line are created as TilePane objects with three elements in them. What I am trying to do is optionally remove either the end two elements of the second and third row or alternatively the middle item depending on a configuration parameter.
What I have tried is the following:
firstRow.getChildren().addAll(leftFront, leftCentre, leftBack);
secondRow = new TilePane();
secondRow.getChildren().addAll(rightFront, rightCentre, rightBack);
leftCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
firstRow.getChildren().remove(leftBack);
firstRow.getChildren().remove(leftFront);
} else {
firstRow.getChildren().remove(leftCentre);
}
});
leftCentre.visibleProperty().bind(labelProp);
rightCentre.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
secondRow.getChildren().remove(rightBack);
secondRow.getChildren().remove(rightFront);
} else {
secondRow.getChildren().remove(rightCentre);
}
});
rightCentre.visibleProperty().bind(labelProp);
Where the elements with left and right named items are the ones I want to remove or keep depending on the SimpleBooleanProperty labelProp
. If I set labelProp
to false the four outer elements appear. However if I set the labelProp
to true only the top line of the three appear.
So what I am doing wrong?
layout javafx-8
layout javafx-8
asked Nov 20 '18 at 3:02
TonyTony
30927
30927
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Worked out my problem. It appears that the initial value of the BooleanProperty was removing the values I expected to see when it was initialised. So when I tried to make them reappear the Nodes had been removed.
Is there a way to make the elements in a TilePane to aligned? For example
First1 First2
Second1 Second2
Is what I am seeing on the screen as I set the TilePane aligment to CENTER. What I want to see is:
First1 First2
Second1 Second2
so it looks a little neater.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385598%2fjavafx-remove-item-from-tilepane%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Worked out my problem. It appears that the initial value of the BooleanProperty was removing the values I expected to see when it was initialised. So when I tried to make them reappear the Nodes had been removed.
Is there a way to make the elements in a TilePane to aligned? For example
First1 First2
Second1 Second2
Is what I am seeing on the screen as I set the TilePane aligment to CENTER. What I want to see is:
First1 First2
Second1 Second2
so it looks a little neater.
add a comment |
Worked out my problem. It appears that the initial value of the BooleanProperty was removing the values I expected to see when it was initialised. So when I tried to make them reappear the Nodes had been removed.
Is there a way to make the elements in a TilePane to aligned? For example
First1 First2
Second1 Second2
Is what I am seeing on the screen as I set the TilePane aligment to CENTER. What I want to see is:
First1 First2
Second1 Second2
so it looks a little neater.
add a comment |
Worked out my problem. It appears that the initial value of the BooleanProperty was removing the values I expected to see when it was initialised. So when I tried to make them reappear the Nodes had been removed.
Is there a way to make the elements in a TilePane to aligned? For example
First1 First2
Second1 Second2
Is what I am seeing on the screen as I set the TilePane aligment to CENTER. What I want to see is:
First1 First2
Second1 Second2
so it looks a little neater.
Worked out my problem. It appears that the initial value of the BooleanProperty was removing the values I expected to see when it was initialised. So when I tried to make them reappear the Nodes had been removed.
Is there a way to make the elements in a TilePane to aligned? For example
First1 First2
Second1 Second2
Is what I am seeing on the screen as I set the TilePane aligment to CENTER. What I want to see is:
First1 First2
Second1 Second2
so it looks a little neater.
answered Nov 20 '18 at 6:39
TonyTony
30927
30927
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385598%2fjavafx-remove-item-from-tilepane%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown