Closed ctoabidmaqbool closed 1 year ago
I guess you could try setting wrap-text with CSS. Our can even use scenic-view and check whether setting wrap-text results in the wanted behaviour.
I guess you could try setting wrap-text with CSS. Our can even use scenic-view and check whether setting wrap-text results in the wanted behaviour.
I have tried using CSS way too! Even test quickly using Scene Builder (CSS Analyzer) and Scenic View too.
We can simply set absolute height to titled>pane{}
but USE_COMPUTED_SIZE not works e.g. -1
.
I want that height should be auto computed w.r.t text wrapping. If height of title is large enough then wrapping works well. But height not auto computed.
I guess you always have the option to write your own control.
Yes, making custom control is a complex and time consuming task.
I also try using vlookup way to get Title element and then setting pref height.
In short, i try every possibility but still the problem not solved.
I am still working on this, maybe any trick works!
Something like this codding I have tried, that too not works!
Platform.runLater(() -> {
StackPane title = (StackPane) titledPane1.lookup(".title");
title.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
title.setPrefWidth(100);
title.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
title.prefHeightProperty().bind(lbl1.prefHeightProperty());
});
@FlorianKirmaier Okey! I have solved the above issues myself, by using something like this codding:
private Node getView() {
StackPane root = new StackPane();
TitledPane titledPane2 = new TitledPane();
titledPane2.setMinWidth(Region.USE_PREF_SIZE);
titledPane2.setPrefWidth(400);
titledPane2.setMaxWidth(Region.USE_PREF_SIZE);
titledPane2.setAlignment(Pos.TOP_LEFT);
Label lbl1 = new Label(
"5 sample paragraphs for reading test on 1. Traveling in a D. T. C. Bus 2. Look Before You Leap 3. Rising Prices 4. ‘Simple Living, High Thinking’ 5. A Football Match");
lbl1.setWrapText(true);
lbl1.setMinHeight(Region.USE_PREF_SIZE);
lbl1.setPadding(new Insets(0, 4.3, 0, 0));
titledPane2.setGraphic(lbl1);
Label lbl12 = new Label(
"Delhi is a crowded city. There are very few rich people who travel by their own vehicles. The majority of the people cannot afford to hire a taxi or a three-wheeler. They have to depend on D.T.C. buses, which are the cheapest mode of conveyance.");
lbl12.setWrapText(true);
lbl12.setPadding(new Insets(4.3));
titledPane2.setContent(lbl12);
root.getChildren().addAll(titledPane2);
Platform.runLater(() -> {
Pane title = (Pane) titledPane2.lookup(".title");
title.prefHeightProperty().bind(lbl1.heightProperty()
.add(title.getInsets().getTop() + title.getInsets().getBottom()));
});
return root;
}
Output:
But it's more better if it's fixed in official javafx or jpro-one -> custom javafx.
@ctoabidmaqbool Great to hear you've fixed your problem! We've made a lot of fixes for JavaFX bugs and have been playing with the thought of our own JavaFX Fork for quite some time, mainly because we've got a lot of bugfixes that are not yet in the official JavaFX.
I'm closing the ticket now.
Hi! I am making FAQ's page in JPro. I am using TitlePane for this purpose. But It's have issue of Text wrapping, is any solutions there???
Expected behavior, The Title bar of TitlePane should be auto resize (e.g. w.r.t. Height) as of (HTML) when there is not enough width and text is large then width.
I know it's Javafx Issue not JPro. However any solutions?