PrefWidth/Height calculations only works if stage is shown
John Smith
John_Smith at symantec.com
Wed Aug 28 12:18:51 PDT 2013
I hadn't seen the applyCSS conversation, but looks like it was contained deep in a node validation thread:
http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-July/008549.html
Looks like the request is already covered in RT-21206 as pointed out by David.
Looks like the feature will show up some time post-Java8, which is why there is nothing on Node now.
For now, I stick with Kevin's node snapshot workaround:
// create a dummy scene so layout and CSS will work
new Scene(new Group(node));
node.shapshot(...)
Thanks for the info!
-----Original Message-----
From: Richard Bair [mailto:Richard.Bair at oracle.com]
Sent: Wednesday, August 28, 2013 11:46 AM
To: John Smith
Cc: Anton Epple; openjfx-dev at openjdk.java.net
Subject: Re: PrefWidth/Height calculations only works if stage is shown
I could have sworn we have already had this conversation and we had a name picked out and everything (maybe it was applyCSS?). I don't see it in Node yet though.
Richard
-----Original Message-----
From: David Grieve [mailto:david.grieve at oracle.com]
Sent: Wednesday, August 28, 2013 11:52 AM
To: John Smith
Cc: openjfx-dev at openjdk.java.net List
Subject: Re: PrefWidth/Height calculations only works if stage is shown
There is https://javafx-jira.kenai.com/browse/RT-21206, which I've just edited to be public.
On Aug 28, 2013, at 2:29 PM, John Smith <John_Smith at symantec.com> wrote:
> Is there any plan to make impl_processCSS(true) public API?
> Should I create a Jira for this?
> If there were a public API, would processCSS be the right name for it?
>
> The real issue seems to be that you sometimes want to know the size of something before you show it and there doesn't seem to a good way to get that info using just the public API (that I know of).
>
> -----Original Message-----
> From: openjfx-dev-bounces at openjdk.java.net
> [mailto:openjfx-dev-bounces at openjdk.java.net] On Behalf Of Anton Epple
> Sent: Wednesday, August 28, 2013 7:02 AM
> To: Richard Bair
> Cc: openjfx-dev at openjdk.java.net
> Subject: Re: PrefWidth/Height calculations only works if stage is
> shown
>
> That is very useful in many contexts. Thanks for sharing!
>
> --Toni
>
> Am 08.08.2013 um 23:40 schrieb Richard Bair <Richard.Bair at oracle.com>:
>
>> The peers don't impact the preferred sizes at all. Use this one
>> instead of impl_reapplyCSS (wrong one)
>>
>> impl_processCSS(true)
>>
>>
>> On Aug 8, 2013, at 2:35 PM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
>>
>>> No same result!
>>>
>>>> BorderPane g = new BorderPane();
>>>> TableView<String> v = new TableView<String>(); g.setCenter(v);
>>>> Scene s = new Scene(g); primaryStage.setScene(s);
>>>> g.impl_reapplyCSS(); System.err.println(g.prefWidth(-1)); // 0
>>>> primaryStage.show();
>>>
>>> Could it be that this does not work because if a stage is not yet
>>> shown the peers have not been created?
>>>
>>> Tom
>>>
>>> On 08.08.13 23:29, Richard Bair wrote:
>>>> Yes, the problem is that CSS has not been executed yet. If you call reapplyCSS (did we add that API yet? or is it still that impl_?) then you can get a proper size from the control.
>>>>
>>>> Richard
>>>>
>>>> On Aug 8, 2013, at 2:26 PM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I've been trying to open a window in the minimal dimension needed
>>>>> by components but it looks like size calculations
>>>>> prefHeight/prefWidth only works if the stage is shown.
>>>>>
>>>>> I need the dimensions before showing the stage because I want to
>>>>> position it on the lower right of the screen before showing the
>>>>> stage because if doing it afterwards leads to flickering.
>>>>>
>>>>>
>>>>>> BorderPane g = new BorderPane();
>>>>>> TableView<String> v = new TableView<String>(); g.setCenter(v);
>>>>>> Scene s = new Scene(g); primaryStage.setScene(s);
>>>>>> System.err.println(g.prefWidth(-1)); // 0 primaryStage.show();
>>>>>> System.err.println(g.prefWidth(-1)); // 248
>>>>>
>>>>> Is this working as designed?
>>>>>
>>>>> Tom
>>>>
>>>
>>
>
More information about the openjfx-dev
mailing list