Re: Backport for [JDK-8131151] Pressing ESC in a nested alert closes self and parent alert

2015-09-28 Thread Werner Lehmann

Hi Jonathan,

that's all I am asking. Thanks,

Werner

On 28.09.2015 01:41, Jonathan Giles wrote:

I have no issue picking up this backport and attempting to get it into
an 8u release. No promise though.

-- Jonathan




Backport for [JDK-8131151] Pressing ESC in a nested alert closes self and parent alert

2015-09-24 Thread Werner Lehmann

Hi,

since there seems to be an opportunity to have fixes backported to 8, 
I'd like to ask for a backport of the fix for


[JDK-8131151] Pressing ESC in a nested alert closes self and parent alert
https://bugs.openjdk.java.net/browse/JDK-8131151

Looks as if the fix is pretty simple. Without this we seem to be forced 
to disallow closing dialogs with escape key because the following 
yes/no/cancel alert would be dismissed right away from the same 
keypress. Admittedly, it is not critical in any way but the backport 
risk should be low.


Rgds
Werner


Re: Use of clipping in TabPaneSkin

2015-09-06 Thread Werner Lehmann

Hi Pedro,

from my understanding there is no automatic clipping feature on control 
bounds. If the tabpane could not grow to accomadate its content, the 
content would overlap the tabpane bounds if it is bigger. You can find a 
similar pattern on the titledpane for example.


Werner

On 06.09.2015 23:06, Pedro Duque Vieira wrote:

Hi,

Yes but isn't that redundant, you're setting the clip equal to the width
and height of the component so to me it seems that it's not doing anything.
I would understand if the clipping area was for a part of the component,
not for the whole component.

Probably I'm missing something.

Thanks, best regards,


Re: Use of clipping in TabPaneSkin

2015-09-05 Thread Werner Lehmann

Hi,

On 04.09.2015 19:54, Pedro Duque Vieira wrote:

What's the purpose of this?


looks as if there is a clipping rectangle being updated whenever 
width/height of the clipped area changes?


Werner


Re: JavaFx: printer dialog is shown behind main window(stage)

2015-06-15 Thread Werner Lehmann

Hi Alexander,

this seems to be a known bug:
https://bugs.openjdk.java.net/browse/JDK-8088395

Rgds
Werner

On 15.06.2015 07:54, Александр Свиридов wrote:

The printer dialog appears. But! it appears behind the main window
but not in front of main window! This strange behaviour happens only
when dialog appears the first time. The second and other times it's
in front of the main window. How to fix it?




Re: slightly ot: java9 runtime images

2015-05-15 Thread Werner Lehmann

Hi Tom,

could you do this with File.deleteOnExit? Question is, can it delete 
jars on its own classpath...


Werner

On 14.05.2015 08:22, Tom Eugelink wrote:

Unfortunately you cannot have the spawned JVM cleanup after itself, otherwise I 
could stop the initial JVM after it spawned the other.


Re: Maximum size of a canvas?

2015-05-15 Thread Werner Lehmann

Hi Jeff,

interesting idea although I am not sure in which way this improves 
things. I am already scaling the canvas node if it is bigger than 
necessary (due to previous zoom, works like supersampling then) or 
smaller than necessary (if the maximum size is reached but I need to 
present the content bigger than that).


Looks as if the scaling of the canvas and the scaling of the 
graphicscontext might both be applied at the same time - unless one is 
simply a shortcut to the other. I have to experiment on this one.


Rgds
Werner

On 15.05.2015 16:15, Jeff Hain wrote:

Instead of creating an eventually (and quadratically) huge canvas,
you could try using Canvas.getGraphicsContext().scale(2
double)/translate(2 double),
and bind the scroll bars to the {canvas dimensions, applied transform}
data.


Maximum size of a canvas?

2015-05-13 Thread Werner Lehmann

Hi,

is there a way to somewhat safely determine the maximum size of a 
canvas? I am using the canvas to display a report result in a custom 
report viewer control. The report can be zoomed in which basically means 
that I recreate the canvas with a bigger size (the canvas is inside a 
scrollpane).


On previous experiments I discovered that it is probably not safe to use 
more than twice the screen width or height, according to


  Screen.getPrimary().getBounds()

Turns out that might be too optimistic since I just had my application 
lock up: the application thread was waiting on a countdownlatch. Since 
this was in the debugger I could suspend all threads and the quantum 
thread was busy in


  com.sun.prism.d3d.D3DResourceFactory.nCreateTexture

At that time the canvas size was 3396.0 x 2400.0 for a screen resolution 
of 1920 x 1200. I can reproduce this every time now. If I change the 
code so that the canvas size never exceeds either width or height of the 
screen (up to 1698.0 x 1200.0) the problem goes away but then of course 
I have less quality on a 400% zoom...


Rgds
Werner


Re: QML vs. FXML

2015-03-05 Thread Werner Lehmann

Like this?

http://wiki.eclipse.org/Efxclipse/Tooling/FXGraph

On 05.03.2015 16:23, Doug Schaefer wrote:

You really want to use a domain specific language that’s easy to read
and write. QML is that. I find XML tags overwhelm the rest of the
text making it hard to understand what’s going on, and hard to write
unless you have a good XML editor.  QML has less cruft and it’s
easier to see what’s happening with a quick glance.




Re: focus property in composed control

2015-02-23 Thread Werner Lehmann

Hi Tom,

lately I've been battling similar issues. One important thing I learned 
here is that if my custom control wraps a TextField in its skin I have 
to make sure that the custom control is not focus-traversable.


It also seems difficult to have focus on the custom control in terms of 
Node.focused while actual focus is on the TextField in the skin. 
ComboBox may have the same issue with its embedded TextField. At least 
the FakeFocusTextField inside the ComboBoxListViewSkin looks like a 
workaround for this. But I can't do the same because this uses (package) 
private API.


And the creative implementation of Node.FocusedProperty (to make sure 
that focus switch is an atomic change for focus change listeners) 
reminded me of Tomas' latest posting about Suspendable listener 
notifications. This would be nice to have in FX so we don't need 
private workarounds...



http://tomasmikula.github.io/blog/2015/02/10/val-a-better-observablevalue.html


Werner

On 23.02.2015 09:03, Tom Eugelink wrote:

What would be the best way to forward the focusProperty of the
TextField to the control's focusProperty?


Re: Question/feedback regarding Windows Hi DPI support and how it will affect applications

2015-02-18 Thread Werner Lehmann

Hi Jim,

interesting read. I guess I learned more about the topic than I can 
help. Also found this resource interesting:


http://kynosarges.de/GuiDpiScaling.html

Some thoughts. Obviously it is less desirable to require every 
application to do their own scaling. I can't imagine that this would 
work on a larger basis. As to the question of integer vs float 
coordinates, there is a lot of snapToPixel stuff going on. And one of 
the reasons is to get crisp pixel-aligned lines. Snapping to logical 
coordinates could then snap to non-integer physical coordinates (if the 
scaling factor is 125% or somesuch). Which may be ok if hidpi makes up 
for it...


As to em-based styling, I was under the impression that there was a 
constant factor for 1em. Reading section RESIZING FOR DIFFERENT SCREEN 
DPI in modena.css I am not so sure anymore. The resource above also is 
unsure (FWIW):


JavaFX em handling is inconsistent, sometimes referring to the 
automatically acquired system font but at other times yielding a 
hard-coded default size.


Finally, it would be nice to get information about the actual screen 
DPI. In my tests Screen.getDpi always returns 96, regardless of what it 
actually is...


Werner


Re: Question/feedback regarding Windows Hi DPI support and how it will affect applications

2015-02-18 Thread Werner Lehmann
My usecase is not about retina or not. It is about showing a report 
result in actual size which means I need to scale it depending on the 
screen DPI.


Current workaround is this...

-Dcom.sun.javafx.screenDPI=109

...but I can't really advertise this to users.

Werner

On 18.02.2015 12:23, Mike Hearn wrote:

You can reflectively access Screen.getPixelScale() to learn if you're on
Retina. Of course, don't expect to swap out the JRE for a newer one
automatically if you do this (I bundle so it's not so problematic).


Re: How to apply skin?

2015-02-09 Thread Werner Lehmann

Hi Tomas,

I think the expected way of doing this is to defer the code which 
requires the control width until normal layout passes come across it. Or 
maybe not only defer that code but actually move it to layouting methods.


Werner

On 09.02.2015 00:51, Tomas Mikula wrote:

Actually, I want skins to be applied in the whole sub-tree of a node.
The node itself may not be a control, but it may contain controls.


Re: Event Filtering

2015-02-09 Thread Werner Lehmann

Hi Scott,

at least in Java 8 you can override TextInputControl#replaceText and/or 
TextInputControl#replaceSelection to convert lowercase into uppercase. I 
have used it for exactly this purpose.


Werner

On 07.02.2015 01:33, Scott Palmer wrote:

But let's say that I want to allow the user to type lowercase letters and
have them appear in uppercase.  I don't ever want the text property of the
TextField to hold a lowercase character.  Can that be done?


Re: Event Filtering

2015-02-09 Thread Werner Lehmann
I see. Looks as if the textfield in a combobox cannot be subclassed 
because of final restrictions. As a last resort, you could use your 
own textfield as a buttoncell - which would of course skip over all 
special handling for editable comboboxes in the skin...


Werner

On 09.02.2015 12:44, Scott Palmer wrote:

When the actual control is an editable combobox it gets more
complicated. That is the case that prompted my original message.


Re: Label prefHeight vs wrapText

2015-02-05 Thread Werner Lehmann
Sorry to dig up this old thread. Just wanted to mention a much simpler 
workaround if a label inside a vbox does not wrap its text:


label.setMinHeight(Region.USE_PREF_SIZE);

As before the trick is to prevent vbox from reducing the label height 
below its pref height to preserve the wrapping - even if other children 
of the vbox need to be shrunk.


Werner

On 28.05.2014 18:10, Werner Lehmann wrote:

Martin,

thanks for the explanation. Feels good to finally understand this ;-)
And while I created a ticket as per your suggestion...

[#RT-37309] VBox: vshrink layout hint similar to vgrow

...it seems I can use this as a workaround:


 label1.minHeightProperty().bind(Bindings.createDoubleBinding(
 () - label1.prefHeight(vbox.getWidth()),
 vbox.widthProperty()));


Maybe something similar could be made available per label boolean
property. So basically the ability to ask a label to consider wrapping
when calculating its minHeight... I can imagine that this might have
made more sense as a default behavior: if people explicitly ask for
wrapping text, they would probably accept a larger minHeight.

Werner


Re: CSS under 1.8.0_40 not identical to 31 or older

2015-02-05 Thread Werner Lehmann
FWIW, we are also experiencing css differences between 8u25 and 8u40. In 
some custom controls portions appear completely unstyled on 8u40, as if 
the selectors would stop working. Couldn't take a closer look so far due 
to time constraints...


Werner


Re: Is it possible to have a SwingNode inside a JFXPanel

2015-01-28 Thread Werner Lehmann

We have had both scenarios and encountered issues in these areas:
- dragdrop inside the component/node and between swing/fx
- repaint issues, sometimes the jfxpanel would appear all black
- resize issues, changes to the content of either swingnode or jfxpanel 
would not be passed to the containing element

- can't tab from components in a jfxpanel to nodes of the containing scene
- for a combobox in a jfxpanel in a swingnode: can't select elements 
from the dropdown, even clicking the dropdown scrollbar would close the 
dropdown
- reduced framerate / increased cpu load inside jfxpanel, especially for 
animations


Some of these are resolved, others are not (issues were reported). I'd 
recommend to test the above early if relevant for your application.


Werner

On 27.01.2015 20:36, Pedro Duque Vieira wrote:

Hi,

I'm migrating a Swing app and I have a scenario where I need to have a
SwingNode inside a JFXPanel and also a JFXPanel inside a SwingNode.

Are this configurations possible?


Re: How to use scaleX/Y to change layout bounds?

2015-01-28 Thread Werner Lehmann

Hi Tobi,

wrap the button into a group.

Werner

On 28.01.2015 07:51, Tobias Bley wrote:

Hi,

when I call button.setScaleX(.5) and button.setScaleY(.5) the button
changes it’s size only visually - the layout  bounds does not change…
How can I change this behaviour?

Best regards, Tobi




Re: TableView API, no lazy retrieval of visible cell content possible?

2015-01-28 Thread Werner Lehmann

Robert,

I think Tomas is right, load your thumbnails on demand when updateItem 
is called for an item with missing thumbnail. You say that the cell of a 
visible item gets reused for another item. If that is the case I guess 
that the item is moved to another cell. Wouldn't it be possible to 
have an image property on your items and the lazy loading is done on the 
item, triggered when the item is passed to updateItem of any cell? That 
should trigger the demand-loading and it would be robust against the 
tableview exchanging cells for individual items.


As to the question when to start or stop lazy loading for items, I would 
add the load-demands to a stack. Each time the image for a new item is 
requested it is put to the top of the stack and you have one or more 
threads processing items on the stack (LIFO). An an image is requested 
which is already on the stack move it to the top of the stack. If an 
item is removed from a cell remove it from the stack. That should do it.


Werner

On 28.01.2015 09:30, Robert Krüger wrote:

Doesn't help. The patterns of this property being changed are just as
unusable for my purposes as with the other approaches (e.g. I can clearly
see that item is set to a different value for a cell that is still visible,

...



Re: switching skins at runtime

2014-12-29 Thread Werner Lehmann

I think this is something you need to do in SkinBase.dispose.

Werner

On 26.12.2014 22:55, Tom Eugelink wrote:

Hm, I've got it working, but I need to call a getChildren().clear()
before I start creating nodes in a skin. If not, the control will
retain the nodes an old skin has created. Also any style classes that
were assigned remain, but those can be reset easily.

Never the less I feel that setSkin() should clear the children and
reset the style classes itself?


Re: switching skins at runtime

2014-12-29 Thread Werner Lehmann
That's what I meant: clear children, or undo whatever you are doing to 
them, in dispose(). At any rate I wouldn't know if that is correct. It 
is just how I assume this would work.


On 29.12.2014 11:44, Tom Eugelink wrote:

That works for unbinding listeners to skinnable and the reset code for style 
class, I still need to clear the childeren.

Tom


Select-binding still warns about null steps

2014-12-15 Thread Werner Lehmann

Hi,

it seems as if bindings created with Bindings.selectXXX still do not 
support null steps fully. With RT-35957 the log level of NPEs caused by 
null steps was reduced to FINE. Howver, in 8u25 there is a still a 
warning logged for a perfectly normal operation:



Dez 15, 2014 12:59:44 PM 
com.sun.javafx.binding.SelectBinding$SelectBindingHelper getObservableValue
WARNING: Exception while evaluating select-binding [window]


Example code:


  @Override
  public void start(Stage primaryStage) throws Exception
  {
ObjectBindingObject binding = Bindings.select(primaryStage.sceneProperty(), 
window);
binding.get();
  }


Explanation for this seems obvious, on level WARNING there is at least 
one line logged always, unaffected by the change to FINE:



final PlatformLogger logger = Logging.getLogger();
if (logger.isLoggable(Level.WARNING)) {
Logging.getLogger().warning(Exception while evaluating 
select-binding  + stepsToString());
if (ex instanceof  IllegalStateException) {
logger.warning(Property ' + propertyNames[i] + ' does 
not exist in  + obj.getClass(), ex);
} else if (ex instanceof NullPointerException) {
logger.fine(Property ' + propertyNames[i] + ' in  + 
properties[i] +  is null, ex);
} else {
Logging.getLogger().warning(, ex);
}
}


As a result I am getting exception warnings logged leading to questions 
leading to explanations and bug tickets etc. I tried to work around it 
by reducing the log level:


- created file logging.properties in classpath root with content 
beans.level = OFF

- added VM argument -Djava.util.logging.config.file=logging.properties

While this works standalone it does not seem to be accepted in a 
Webstart JNLP file because it is not a whitelisted secure property.


Any ideas about that?

Thx,
Werner


Re: Scrollbars on *View or better VirtualFlow based UI elements

2014-12-15 Thread Werner Lehmann

Hi Tomas,

On 15.12.2014 16:10, Tomas Mikula wrote:

To add an idea, semi-transparent scrollbars could be shown over the
content when the mouse approaches the edge. This would avoid
flickering andto save space at the same time. I realize one could not
use this if the scrollbars would cover some interactive controls at
the edge of the content.


Sounds similar to invisible scrollbars which appear on hover only. 
Personally I don't like either one. I guess it is a matter of taste. In 
a touch scenario it is a bit of problem though because usually you 
cannot rely on hover events.



Also, I would like to see some new creative way of scrolling the
content, especially for cases when the full length of the content is
not known, e.g. a ListView with variable cell sizes, or a possibly
infinite stream of items that are loaded as needed. In these cases,
the scrollbar length always lies about the actual total length of the
content.


If you have variable cell sizes an easy way to map this to a scrollbar 
is to use the number of items, possibly with some adjustments involving 
the height of the known cells. From my impression this is what virtual 
flow does but I could be wrong.


An infinite stream of items can be scrolled with the Google Picasa 
light table approach. You can find an implementation of this concept in 
ControlsFX, see the PlusMinusSlider control.


Werner


High resolution printing

2014-12-09 Thread Werner Lehmann

Hi,

I'd like to print a canvas node with native printer resolution. What is 
the best way to achieve that? I suppose I can't just set the canvas 
width and height to the printer page size equivalent because at 600 DPI 
this would mean about 5000x7000px. And as far as I know a canvas this 
size can be a problem. Aand there are printers with even higher resolutions.


Should I print to a 72 DPI canvas instead, e.g. 600x850px? My content is 
not bigger than this anyway, talking about Jasperreports rendered at 72 
DPI to an AWT graphics surface. Still I'd like to make use of higher 
print resolution to get crisp text and to avoid pixel upscaling.


Looks as if it was intended to provide a printer canvas but I guess 
such API is not available.

https://wiki.openjdk.java.net/display/OpenJFX/Printing+for+JavaFX

Alternatively I could skip the FX printing API altogether and use AWT 
graphics printing. Maybe it is the best option this content.


Any recommendations?

Rgds
Werner


Re: High resolution printing

2014-12-09 Thread Werner Lehmann

Hi Kevin,

yes it has, and my users can save their reports to a PDF file, open it, 
and print it. I just felt there should be a more direct way to print a 
report.


Anyway, I decided to use Jasper's built-in print-exporter which works 
with Java 1.4 AWT printing. This means I have a working solution which 
unfortunately does not use the FX printing API. As a consequence, print 
dialogs look a bit dated and are not modal on my stage. However, even 
with FX printing dialogs would not be modal (RT-27983), only to be 
resolved with Java 9...


Werner

On 09.12.2014 19:12, Kevin Loverde wrote:

Doesn't Jasperreports have a PDF rendering method? That might be a
simpler route.


Re: Classpath-relative URLs in CSS

2014-10-15 Thread Werner Lehmann

Hi David,

classpath-relative URLs in CSS do not seem to work, unfortunately. For 
example,


  -fx-background-image: url(/mint/report_16x16.png);

has no effect. Relative addressing does work. Looks to me as if there is 
a bug in com.sun.javafx.css.converters.URLConverter.resolve. Basically 
it seems to work like this:


- if url is absolute (has a scheme, e.g. http), use it verbatim
- if stylesheet url is present, use that to resolve the image url
- otherwise go to contextclassloader

I don't get to the last step because the stylesheet url in the second 
step is always present. Am I seeing things, or is there another way to 
do this?


By the way, even with relative addressing I still cannot access images 
during debugging in Eclipse if the stylesheet is in a different Eclipse 
project than the referenced image resource. This really hurts 
modularization and resource reuse (or I am forced to do this in code). 
Any idea about that?


Rgds
Werner


On 01.06.2012 04:03, David Grieve wrote:

In the current implementation, absolute paths without a scheme are
not resolved relative to the class path. I have created RT-21967 to
track the issue.


Re: Classpath-relative URLs in CSS

2014-10-15 Thread Werner Lehmann

Hi,

sure, I'll create a ticket. This is on 8u11. Please see also below.

On 15.10.2014 14:36, David Grieve wrote:

Two pieces of information are passed into the converter. The first is
the value that was given in the style, e.g., /mint/report_16x16.png.
The second is the URL of the stylesheet as determined when the
stylesheet is loaded. The stylesheet URL may be null, as would be the
case for an in-line style.


Ok, in my case the style is not inline but in a stylesheet. When 
execution gets to this conditional inside URLConverter.decode,



if (stylesheetUrl != null  stylesheetUrl.trim().isEmpty() == false) {


it always enters that block and finds a return statement. Only after 
that block the classloader would be asked but it never gets there. I can 
imagine it would work with an inline style.



If the resource is copied over to the build directory that eclipse uses
on the class-path, then there shouldn't be a problem.


The resource must be copied to the bin directory because I can access it 
in code even if the resource is in another project. But CSS doesn't see 
it - that's what puzzles me so much.


Werner


Re: Classpath-relative URLs in CSS

2014-10-15 Thread Werner Lehmann

Here's the ticket. Tried it also on 8u25, same result.

https://javafx-jira.kenai.com/browse/RT-38991

Werner

On 15.10.2014 16:25, Werner Lehmann wrote:

sure, I'll create a ticket. This is on 8u11.


Re: CSS: style leaks from unrelated stylesheet

2014-10-09 Thread Werner Lehmann

Thanks, David.

This means I would always override getUserAgentStylesheet (for 8u20 on 
Control, for 8u40+ on Region). And selectors in the stylesheet should be 
sufficiently specific because only 8u40+ actually limits them to the 
declaring node.


For the record, I'm not talking about controlsfx - but that may have 
been the template for it.


Werner

On 09.10.2014 15:27, David Grieve wrote:

In 8u20 and before, adding a stylesheet via
Control.getUserAgentStylesheet will simply add the user-agent stylesheet
to the entire scene, not just the control. This has been fixed in 8u40
where the getUserAgentStylesheet method is now public API on Region and
the styles added will affect only the Region and its children.

Incidentally, the code you point out from the 3rd party control
(controlsfx) was added as a work-around for a separate issue related to
Control.getUserAgentStylesheet(). I believe the 8u40 branch of
controlsfx has removed this work-around and is using the
Region#getUserAgentStylesheet method.

On 10/9/14, 8:58 AM, Werner Lehmann wrote:

Turns out that the 3rd party control adds its stylesheet like this:

class SomeControlSkin...
   static {
 StyleManager.getInstance().addUserAgentStylesheet(...)
   }

In this way it is not only using private API but also the stylesheet
is not associated with only such control nodes and therefore seems to
affect other nodes, too. Is this correct, and should the stylesheet
rather be provided by overriding Control.getUserAgentStylesheet?

Werner

On 09.10.2014 12:00, Werner Lehmann wrote:

Then a dialog stage is displayed and its scene does not use the 3rd
party control. However, a combobox list-cell (its button cell) is still


Re: openjfx-dev Digest, Vol 34, Issue 36

2014-09-22 Thread Werner Lehmann

Hi Daniel,

actually, as it turns out that code did not even compile with javac 8u11:


[mint.javac] [...] error: package sun.util.logging.PlatformLogger does not exist
[mint.javac] 
com.sun.javafx.binding.Logging.getLogger().setLevel(sun.util.logging.PlatformLogger.Level.OFF);


Eclipse's JDT did not have a problem. Looks to me as if javac actively 
protects that package. After exploring a few options to configure 
logging in code only it looks as if the only way is to really do this 
with a vm argument. Without WebStart it seems to be sufficient to use 
System.setProperty first thing in the main method but with WebStart 
there is no main method and it could be too late when doing it in 
Application.start.


So, until 8u20 I am doing this:

in JNLP or vmarg with -D:
java.util.logging.config.file=logging.properties

logging.properties:
beans.level = OFF

Also, I am not sure if java.util.logging.config.file is a trusted 
property for the jnlp file. I'll have to see about that.


Werner

On 22.09.2014 09:41, Daniel Fuchs wrote:

Hi,

I don't recommend using sun.* proprietary APIs.
The safest way to suppress the logger output would be to
switch it off in a logging.properties file.

-Djava.util.logging.config.file=logging.properties

and inside:

logger-name.level = OFF

best regards,

-- daniel


How to suppress platform logger output

2014-09-19 Thread Werner Lehmann

Hi,

I'd like to use one of the Bindings.select* methods but can't really 
accept the tons of stderr output it generates for null steps. According 
to this ticket...


[#RT-35957] Bindings class spits out a lot of unneeded log messages
https://javafx-jira.kenai.com/browse/RT-35957

... 8u20 resolves this by logging on the FINE level. But how can I 
suppress this output then? As far as I know the platform logger logs to 
stderr if JDK logging is not used - and we are on log4j. Which means I 
get FINE logging on stderr which does not help much.


Rgds
Werner


Sep 19, 2014 1:33:32 PM 
com.sun.javafx.binding.SelectBinding$SelectBindingHelper getObservableValue
WARNING: Exception while evaluating select-binding [parent, value]
Sep 19, 2014 1:33:32 PM 
com.sun.javafx.binding.SelectBinding$SelectBindingHelper getObservableValue
INFO: Property 'value' in ReadOnlyObjectProperty [bean: TreeItem [ value: b ], 
name: parent, value: null] is null
java.lang.NullPointerException
at 
com.sun.javafx.binding.SelectBinding$SelectBindingHelper.getObservableValue(SelectBinding.java:481)
at 
com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:394)
at javafx.beans.binding.StringBinding.get(StringBinding.java:152)
at 
mint.javafx.report.design.model.elements.MintJRTextField.main(MintJRTextField.java:182)



//TreeItemString t1 = new TreeItemString(a);
TreeItemString t2 = new TreeItemString(b);
TreeItemString t3 = new TreeItemString(c);

//t1.getChildren().add(t2);
t2.getChildren().add(t3);

StringBinding binding = Bindings.selectString(t3, parent, parent, 
value);
System.out.println(binding.get());




Re: How to suppress platform logger output

2014-09-19 Thread Werner Lehmann

Hi Nicolai,

On 19.09.2014 15:43, Nicolai Parlog wrote:

a little off topic but it might still be relevant for you.


thanks, I noticed that ticket and found Tomas' blog to be a very 
interesting read. However, this is for a Webstart application and we 
already have way too many dependencies for me to add another because it 
is convenient for one occassion. If it weren't so much boilerplate to do 
this I would probably quickly hack it up myself :)


Werner


Re: How to suppress platform logger output

2014-09-19 Thread Werner Lehmann

Hi Peter,

this one seems to work, based on your former suggestion:

com.sun.javafx.binding.Logging.getLogger().setLevel(sun.util.logging.PlatformLogger.Level.OFF);

Thanks for that. Of course I am not sure if that also kills other 
binding-related logs I might be interested in but generally I'd prefer a 
runtime exception anyway. And in this particular case of a select 
binding it is normal operation to come across null values.


About the slf4j bridge, I had shortly looked into it but it feels a bit 
extreme to add a jar file, modify logging, and pay the perfomance 
penalty mentioned on that site to get a selectString binding :)


Werner

On 19.09.2014 16:46, Peter Levart wrote:

Alternatively, you can have PlatformLogger output through Log4J. Use
jul-to-slf4j bridge and slf4j-Log4J backend.

See here:

http://www.slf4j.org/legacy.html#jul-to-slf4j




Re: Close all ContextMenu with mouse button

2014-09-18 Thread Werner Lehmann

On 18.09.2014 14:38, Anthony Petrov wrote:

If they don't, this is a bug in either Control, Scenegraph, or Glass.
Please file a JIRA and provide a small test case that reproduces the
problem.


...or a JFXPanel is involved: popups and contextmenus opened from a 
JFXPanel do not close when clicking in Swing (outside of the JFXPanel). 
At least it used to be like that in FX 2.2.


Werner


Re: Skin layoutChildren: when to get bounds of child nodes?

2014-07-31 Thread Werner Lehmann

Hi Martin,

On 30.07.2014 17:39, Martin Sladecek wrote:

I assume you don't change child1 Nodes, so it should work.


I may add/insert such nodes but in that case I take the easy route and 
simply rebuild the complete hbox.



Yeah, one problem with layouts is when you want to do some layout that
is almost the same as some predefined layout, but you need to tweak it
somehow. Maybe in the future we could add some abstraction and extract
some (parts of) the algorithms we use in our layout containers so they
can be reused in custom layouts.


Right. I noticed some package private methods used internally by vbox 
etc. This prevents me from making a copy of vbox which I can tweak 
(often times removing many properties and lots of code not applicable to 
that usecase). I suppose they could also be useful for other layouts 
occasionally.


I figured if I would use translateX for the tweak I should be fine. For 
the width I might be able to use scaleX but that does not feel right.



If you reuse some predefined layout, you'll probably end up with some
hacky code since you'll usually mess up with the inputs for the layout.
The rule of thumb is to use some more complex (GridPane) or free form
(AnchorPane) layout instead of trying to slightly tweak some simple layout.
In your case, wouldn't GridPane do the job? Basically, you have a row of
text nodes and you need a second row where a single rectangle is in the
same column as currently selected (?) text node. The size of the
rectangle can be set to fillWidth the column, so GridPane will do all
the work for you.


AnchorPane might be applicable for this particular thing. The challenge 
here is then to figure out the heights of elements so that I can stack 
them to get a result similar to the vbox. For example, if I anchor the 
hbox to the top of the AnchorPane and I want to have my moving rectangle 
right below it I have to set static AnchorPane properties on that 
rectangle and have to know the height of the hbox. Again I need to 
position one element based on the default layouting of another. And if I 
am not mistaken it could be difficult to animate those static properties.


I try to avoid GridPane because inserting and removing stuff means to 
manually shift all subsequent indexes which is a bit tedious. Also, if I 
want to animate an element moving from one cell to another it seems to 
get in the way - or at least it does not offer any benefit over the 
current vbox/hbox approach.


Werner


Re: Skin layoutChildren: when to get bounds of child nodes?

2014-07-30 Thread Werner Lehmann

Richard,

since I need to get x and width of child1 (the one inside the hbox) I 
have to use boundsInParent. According to the docs layoutBounds.x/y are 
always zero for resizable nodes so it does not work here. As to the 
question whether the parent might be size 0: the HBox is indeed size 0 
after the initial call to super.layoutChildren. The containing VBox has 
some 800x400 px though.


I think the reason is probably in Martin's reply although I may not like 
it ;-)


Werner

On 25.07.2014 18:56, Richard Bair wrote:

Hmmm. The first question I have is whether boundsInParent is really
what you want to use, vs. layout bounds. But assuming it is what you
want, why are the bounds zero? This is during the layout pass, which
is the right place to be doing what you’re doing. The super
layoutChildren call will size everything based on the contentX,
contentY, contentWidth, contentHeight
(http://hg.openjdk.java.net/openjfx/8u-dev/rt/file/4b8d06211312/modules/controls/src/main/java/javafx/scene/control/SkinBase.java).
Is it possible that the parent itself is size 0? boundsInParent
should always be invalidated automatically whenever the
width/height/transforms/etc changes. If not that is definitely a bug
(that you can write a simple test case for to prove).

But my first guess is maybe the parent is size 0 as well, due to
something else (maybe the pref size of the control is 0 to start with
or something…)

Richard




Re: Skin layoutChildren: when to get bounds of child nodes?

2014-07-30 Thread Werner Lehmann

Martin,

thanks a lot for this elaborate explanation :)  Here's an image of what 
I am talking about.


http://postimg.org/image/t9a6esc71/

child1 is one of the labels in a hbox, e.g. Query or Result
child2 is the blueish region. It needs to be positioned under one of 
those labels. I am doing this with translateX and prefWidth.


On 28.07.2014 07:38, Martin Sladecek wrote:

The super.layoutChildren should size every child of the control (which
is VBox), but not child's children. The control must finish the layout
before children can do theirs. If you need to do layout on some child
before that, you can call .layout() on it. It will do it's layout using
it's current size. You should have all the bounds correct after that call.



But that would not work in your case anyway. You have both childs in a
HBox, which takes care of resizing the children. This means you need to
layout the HBox to get children size and in order to do that, you need
HBox to be at it's final size, which will happen during the VBox layout.
So your steps would be:
1) super.layoutChildren() - VBox is resized to Controls content size
2) now the VBox is resized, you can call vbox.layout()
3) now HBox is resized, so call hbox.layout()
4) children are resized. They have correct layout bounds now. But in
order to get correct boundsInParent (but maybe you really need layout
bounds?), you need to call .layout() on children too.


I my tests it was sufficient to do this:

layoutChildren() {
  ...
  bip = child1.getBoundsInParent()
  if (bip.getMinX() == 0  bip.getWidth() == 0) {
vbox.layout();
bip = child1.getBoundsInParent();
  }
  ...
}

Might not be efficient (or pretty) but seems to work.


Even if you do all these steps, calling setPrefWidth() on child2 marks
the whole tree dirty again. Because HBox needs to resize child2 using
it's new PrefWidth. This also means, HBox prefwidth will be different,
so it's parent (VBox) must do the same. Ditto with the control. Also,
the HBox (VBox, control) may not have enough size to resize child2 to
it's pref width, so child1 might be shrinked as a result, which breaks
your invariant. You are basically changing the input for HBox's layout
(child2.pref size) based on it's output (child1 size), which makes this
a loop.


Makes sense.


So in order to really make this work, you need to manage the child nodes
directly and compute your layout by yourself. This can be done either by
using your own subclass of Pane and overriding it's layoutChildren. Or
if you want to do everything in Skin's layoutChildren, you can make the
children unmanaged, but then it doesn't really matter where they are in
the scenegraph, HBox won't be managing them.

Hope this helps!


It sure does. I have created pane-based controls with manual layouting 
before but it is some work to get it right, especially with the 
computeMinPrefMaxWidthHeight methods (sometimes +baseline), snapsize etc 
pp. I figured it is not worth the hassle here if a vbox and hbox do 95% 
of what I need :)  A cleaner approach would be to make child2 unmanaged 
as you suggest but then I need to reserve vertical space in its vbox 
container, currently done with css padding on the region itself. For the 
time being I have to stick with this and move on.


Thanks again.

Werner


Re: Double.MAX_VALUE in CSS -fx-max-width?

2014-07-28 Thread Werner Lehmann

Hi David,

thanks - here it is:

[#RT-38065] CSS -fx-pref-width et al do not accept infinity value

Werner

On 28.07.2014 05:31, David Grieve wrote:

Hi Werner,

Please file a bug. I'll have to update the parser to accept 'infinity'
as a value.


Double.MAX_VALUE in CSS -fx-max-width?

2014-07-24 Thread Werner Lehmann

Hi,

since FX8 we have a styleable property -fx-max-width on Region. I'd like 
to use this to replace the FXML attribute


Node maxWidth=Infinity/

with CSS

-fx-max-width: Infinity;

This is actually a notation to achieve the equivalent of this code:

  node.setMaxWidth(Double.MAX_VALUE);

Unfortunately it does not work like this in css. Normal values are 
accepted and seem to work but not this one. Maybe there is some special 
handing in the FXMLLoader to treat Infinity like MAX_VALUE? In any case, 
can this be done in css - maybe with a different workaround?


Rgds
Werner


Re: Mirrored observable collections

2014-07-23 Thread Werner Lehmann

Hi,

take a look at Bindings.format and Bindings.createStringBinding for 
that. I use it all the time.


Werner

On 23.07.2014 13:16, Mike Hearn wrote:

Incidentally the lack of a uni-directional string binding utility in JavaFX
is really annoying: converting a read only observable value into a string
is a really common thing to want to do!


Re: ComboBox: TestEditor to ListView binding

2014-07-07 Thread Werner Lehmann

Kirill,

ControlsFX has support for this if a 3rd party lib is ok. With 
TextFields.createClearableTextField() you create a search field with an 
eraser icon to clear the text. And the AutoCompletionBinding applied 
to the textfield implements the auto complete dropdown. You only have to 
provide a function to return search results for user input.


Werner

On 04.07.2014 23:48, Kirill Kirichenko wrote:

I'm implementing a searchbox.
In the textfield of the combobox I'm typing a search string.
textProperty of the editor has an onChange listener which forms a list
of strings that contain the text as a substring. Then I set this list of
strings as a content of the drop down list of the combobox.
The problem is when I start selecting items in the drop down list the
editor field gets updated making new substring search and updating the
list again.
I want to break this dependency. I don't want to update the text
property when I select an item in the drop down list OR I want to
distinguish in the textProperty listener what caused that event - real
editing the field or setting the field trough binding from the list view.

I hope I could make myself clear.
K


Re: New alias for hg commit notifications?

2014-06-24 Thread Werner Lehmann

+1

I was filtering these anyway to a separate mail folder.

Werner

On 24.06.2014 15:34, Kevin Rushforth wrote:

What do others think?


ScrollPane.content moves with arrow keys

2014-06-10 Thread Werner Lehmann

Hi,

we came across a curious behavior of ScrollPane in 8u5: the scrollpane 
content can be moved around with arrow keys if it is smaller than the 
viewport. This can be reproduced in SceneBuilder with simple FXML:



?xml version=1.0 encoding=UTF-8?

?import java.lang.*?
?import javafx.scene.control.*?


ScrollPane maxHeight=-Infinity maxWidth=-Infinity minHeight=-Infinity minWidth=-Infinity 
prefHeight=517.0 prefWidth=272.0 xmlns=http://javafx.com/javafx/8; xmlns:fx=http://javafx.com/fxml/1;
   content
  CheckBox mnemonicParsing=false style=-fx-background-color: red; 
text=CheckBox /
   /content
/ScrollPane


Just a scrollpane with a checkbox in it. It looks like a bug to me but 
maybe I am missing something?


Werner


Re: New skinning in FX8 – where do the style classes go

2014-06-10 Thread Werner Lehmann

Hi Randahl,

see this wiki page...
https://wiki.openjdk.java.net/display/OpenJFX/UI+Controls+Architecture

and below:

On 10.06.2014 19:18, Randahl Fink Isaksen wrote:

Object ◀︎—— SkinBase ◀︎—— MySkin ——  MySkinControl


The new SkinBase is returning a modifiable version of the control's 
children. The FX2 way was actually more convoluted with 
behind-the-scenes copying of properties but I think that is covered on 
the wiki.



One problem is, whenever I have a control MyControl using a skin
class MySkin I used to be able to change the style class of MyControl
and those changes would automatically be reflected by MySkin. Now
with FX8 when I change the style class of MyControl, nothing
happens.


This works for me. Maybe your css selectors need to be adjusted. After 
all the node hierarchy no longer has an extra skin node.



Am I supposed to bind the styleClass property of my MySkinControl
instance to the styleClass of my MyControl instance?


Certainly not.

In my opinion the control creation process is quite simple now. Create a 
new control class, set the style class, and provide the default skin by 
overriding createDefaultSkin(). Here you return an instance of your skin 
which extends SkinBase. Which is where you observe the control 
properties as usual. And use SkinBase.getChildren to add skin content.


Werner



Re: ScrollPane.content moves with arrow keys

2014-06-10 Thread Werner Lehmann

It affects 8u5 as well:

[#RT-37491] ScrollPane content can be moved around with arrow keys
https://javafx-jira.kenai.com/browse/RT-37491

Werner

On 10.06.2014 18:30, Eric Le Ponner wrote:

Curious indeed :)
And probably not intended you’re right.

Note that Scene Builder 2.0 embeds its own jdk.
So it means the problem can be reproduced with FX8 GA release.

Eric




Label baseline offset with a graphic

2014-06-03 Thread Werner Lehmann

Hi,

I am trying to align labels on their baseline in an hbox. This is 
surprisingly difficult if some of the labels have a graphic (on the 
left). Turns out that


   LabeledSkinBase.computeBaselineOffset()

simply uses the max of the text baseline and the height of the graphic:

   h = Math.max(textBaselineOffset, g.prefHeight(-1));

So, if the label has no graphic its height is 17 with baseline 13. With 
a 16x16 graphic the height is still 17 but the baseline changes to 16. 
Which of course messes up the baseline alignment to other controls.


Doesn't it make more sense to use the baseline of the actual text 
(possibly adjusted if the graphic is big)?


Screenshot: http://postimg.org/image/kv12r24z9/

Werner


Re: Label baseline offset with a graphic

2014-06-03 Thread Werner Lehmann

Hi Martin,

excellent - then I don't have to start looking for workarounds.

Werner

On 03.06.2014 14:25, Martin Sladecek wrote:

Hi Werner,
this has changed in 8u20. Seehttps://javafx-jira.kenai.com/browse/RT-36729

-Martin


Re: Resizing stage creates delays in platform.runLater pool?

2014-06-02 Thread Werner Lehmann
We also experienced laggy animation with a stage slide out/down 
animation. The animation would change stage size and it appeared to have 
only 2 or 3 frames. Workaround was to use a different animation style: 
keep stage size but move it 20 px down while changing opacity from low 
to full, both animated. Maybe this is an option for you, too.


Werner

On 02.06.2014 16:20, Guillaume Anctil wrote:

Does anyone know what is at play here, what underlying system creates the
lag and how to avoid this?


Re: Resizing stage creates delays in platform.runLater pool?

2014-06-02 Thread Werner Lehmann
Probably not (that code is gone so I don't know for sure). For some 
other (Mac-related) reason, the software pipeline was already used for 
our internal testing. Didn't seem to make a difference.


FWIW, there was also an NPE occurring if someone was crazy enough to 
show that popup many times by clicking on the button which triggers it - 
while the previous animation did not yet finish. I think two animations 
were competing over the same animated properties if that is even 
possible. Anyway, not an issue anymore.


Werner

On 02.06.2014 17:16, Stephen F Northover wrote:

Does running with the software pipeline fix the problem as suggested in
https://javafx-jira.kenai.com/browse/RT-36796 ?

Steve


Re: Integrating JFX Dialog/Stage in Swing application

2014-05-31 Thread Werner Lehmann

Hi Robert,

the problem with this is that the stage cannot have a swing window as 
its owner. If users misclick the stage will hide behind your main 
window. But if that is acceptable...


Werner

On 31.05.2014 14:27, Robert Krüger wrote:

have a Swing JMenuItem trigger the showing of a JFX stage




Label prefHeight vs wrapText

2014-05-28 Thread Werner Lehmann

Hi,

I am stumped. With a label and wrapText=true I am not getting wrapped 
text when I think I should. Consider this scene (code at bottom):


VBox
  - Label, long text, wrapText=true
  - ListView, prefHeight=1000 (too big to fit)

This will not wrap the label text. The VBox gives all room to the 
listview and keeps the label on a single line. VBox.vgrow does not 
change this.


Without the prefHeight on the listview I am getting wrapped text. Then, 
label height is 34 - while its min/pref/max height is all at 17 
according to ScenicView.


Why is the label not reporting a pref height of 34?
Why is the vbox sizing the label beyond its max height?

Appreciate any insight because I don't see what's going on.

Rgds
Werner




public class WrapTest extends Application
{
  public static void main(String[] args)
  {
Application.launch(args);
  }

  @Override
  public void start(Stage primaryStage) throws Exception
  {
Label label1 = new Label(Strings.repeat(bla , 50));
label1.setWrapText(true);

ListViewString lv = new ListViewString();
lv.setPrefHeight(1000);

VBox vb = new VBox(label1, lv);
Scene scene = new Scene(vb, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
  }
}


Re: Label prefHeight vs wrapText

2014-05-28 Thread Werner Lehmann

Martin,

thanks for the explanation. Feels good to finally understand this ;-)
And while I created a ticket as per your suggestion...

  [#RT-37309] VBox: vshrink layout hint similar to vgrow

...it seems I can use this as a workaround:


label1.minHeightProperty().bind(Bindings.createDoubleBinding(
() - label1.prefHeight(vbox.getWidth()),
vbox.widthProperty()));


Maybe something similar could be made available per label boolean 
property. So basically the ability to ask a label to consider wrapping 
when calculating its minHeight... I can imagine that this might have 
made more sense as a default behavior: if people explicitly ask for 
wrapping text, they would probably accept a larger minHeight.


Werner

On 28.05.2014 16:17, Martin Sladecek wrote:

Hi Werner,
the important min/pref/max height is the one with width parameter as
Label is horizontally biased. So while minHeight(width) == 17,
prefHeight(width) == 34.
But in your case, with ListView's prefHeight == 1000, you'll overflow by
over 400px. VBox does evenly subtract these overflow pixels from
children until it gets to their minimum. Which happens in case of the Label.
Vgrow is ignored when shrinking (see javadoc for setVgrow). Currently,
neither VBox nor GridPane allow you define policy for children when the
pane is below it's pref size and children need to be shrunk. Seems like
a good candidate for a Tweak in JIRA. ;-)
If you need to keep your Label at some height, currently you can only
raise it's minHeight, but I understand that in this case it may be
tricky as it depends on the width.

-Martin


Re: No split-cursor inside JFXPanel

2014-03-12 Thread Werner Lehmann

Hi Anthony,

I noticed the movement on the ticket ;-)  Very good news, thx for 
looking into this!


Werner

On 11.03.2014 18:28, Anthony Petrov wrote:

Hi Werner,

I've re-targeted this bug to 8u20.

--
best regards,
Anthony

On 3/7/2014 9:27 PM, Werner Lehmann wrote:

Hi,

inside a JFXPanel we don't see the split-cursors (e.g. east/west). This
is a known issue:

[#RT-26235] SplitPane in JFXPanel: Mouse cursor not changed
https://javafx-jira.kenai.com/browse/RT-26235

This affects regular splitpanes as well as custom nodes which just use
those cursors. The fix version for this is 9. This is going to be a
highly visible issue in our application when we convert more parts to
JFXPanels this year. Can this fix be done for one of the upcoming 8uXX
releases instead?

Thanks,
Werner


Can't gc a node removed from its scene

2014-02-26 Thread Werner Lehmann

Hi,

I have removed a node from its scene. Node.scene and Node.parent both 
are null. However, inner classes of the Scene seem to keep a reference:


Scene.ClickGenerator.pressedTargets
Scene.ClickGenerator.releasedTargets
Scene.MouseHandler.pdrEventTargets

See http://imgur.com/L8dRQDW for a strong reference chain example. Any 
idea how I can have this cleaned up? Thx... (this is on J7 btw)


Werner


Re: Reloading stylesheets

2013-12-10 Thread Werner Lehmann

Thanks, Tom. Somehow it does not work for me. Any idea?

Basically this is what I am doing:

Parent root = ...
root.getStyleSheets().add(...stylesheets...)
Scene scene = new Scene(root)
StyleManager.getInstance().reloadStylesheets(scene)

Then I show the scene in a JFXPanel, change and save the stylesheet in 
Eclipse, and reopen the window which repeats all of the above. But the 
css changes are not reflected until I restart the application.


On 10.12.2013 13:30, Tom Schindl wrote:

com.sun.javafx.css.StyleManager.getInstance().reloadStylesheets(scene);


Re: Reloading stylesheets

2013-12-10 Thread Werner Lehmann
Got it. The key was to move the stylesheets from the root node to the 
scene before reloading them:


scene.styleSheets.clear
scene.styleSheets.addAll(root.styleSheets)
root.styleSheets.clear
styleManager.reload(scene)

The hotkey also works now: shift+ctrl+7 reloads CSS while the scene is 
visible. This works by using a custom scene, overriding 
impl_processKeyEvent. Even better would be automatic change-detection 
(in debug mode only) but I don't have time to do this now. Previously 
you said that reloading is not needed on FX8... does this work out of 
the box then?


Werner

On 10.12.2013 14:10, Tom Schindl wrote:

My code does:


// Force CSS-Reloading
if( isJavaFX2() ) {
   ReflectiveInvoke.onStyleManagerClass(scene);
}

scene.getStylesheets().clear(); 
scene.getStylesheets().addAll(contentData.cssFiles);


A difference I see is that your stylesheets are on the Root-Container
whereas mine are directly on the Scene.

Tom


Re: Reloading stylesheets

2013-12-10 Thread Werner Lehmann
Interesting. Assuming the stylesheets are still cached, how would it 
know when to reload and not use the cached sheet? Or has sheet 
processing been optimized so much that caching is not necessary anymore...


On 10.12.2013 16:15, Tom Schindl wrote:

No on FX8 you need to remove and readd them! So the only thing different
is that you omit the reload-call on FX8.


Re: Reloading stylesheets

2013-12-10 Thread Werner Lehmann

Makes sense. Thanks!

On 10.12.2013 17:09, David Grieve wrote:

The way it works in 8.0 is that there is a cache of loaded stylesheets. [...]


Re: Look and feel mechanism?

2013-12-09 Thread Werner Lehmann
By the way, platform order of dialog buttons is implemented by the 
ButtonBar control in ControlsFX. It is of course Java8 only but can 
easily be brought back to FX2.


Werner

On 09.12.2013 10:45, Hendrik Ebbers wrote:

Next to the skinning of controls additional features are needed. One
example that was already mentioned is the order of cancel and ok
buttons. Actually there is no support in JavaFX. If basic dialogs
would support this features a definition of the order etc. is needed.
This can be done by using a plugin for the LF API, too.


Re: Focus handling on custom controls

2013-11-21 Thread Werner Lehmann
Interesting idea with those textfield insets. I have noticed that the 
FX2 combobox may not do this right because the cursor can be moved 
behind the combobox button. I'll give it a shot. Would still be nice 
to see how this would be done properly...


Werner

On 20.11.2013 13:57, Scott Palmer wrote:

I did this by putting a TextField and a button in a region, and
positioning the button manually in the layout method to be just
inside the right edge of the TextField. Simple manipulation of the
TextField's insets in the CSS prevents the text from going under the
button. I set the button so that it isn't focusable.  It isn't a
proper skin, but it works for my purposes.

Scott


Focus handling on custom controls

2013-11-20 Thread Werner Lehmann

Hi,

I made a custom control and am trying to get the focus handling right. 
This is a textfield with some buttons on the right hand side, e.g. an 
ellipsis button:


http://i.imgur.com/naPzK1W.png

The control skin basically is an hbox with a textfield and a few 
stackpanes as its children. The question is now how can I have this 
control focused while user input goes into the embedded textfield?


I worked around this by removing focus style from the textfield and 
styling the outer control as focused when the textfield actually has the 
focus - that's a bit faked, of course since the actual focus owner is 
still the embedded textfield. Maybe input events need to be captured on 
the outer control and rerouted to the textfield? How would I adjust 
source/target on the events then?


BTW, this is on FX2 so I don't have layoutChildren(x,y,w,h) - but the 
question would apply to other custom control types, too.


Rgds
Werner


H/V resize cursors in a JFXPanel

2013-11-18 Thread Werner Lehmann

Hi,

still on FX2 I am plagued with a bug that prevents getting h-resize 
(split) cursor in a JFXPanel. This is a known and acknowledged issue, see


[#RT-26235] SplitPane in JFXPanel: Mouse cursor not changed

I have looked some more into this and noticed that this really seems to 
affect the h/v-resize cursors only, other cursors work fine, even on a 
JFXPanel. So I am wondering if this might be related to


[#RT-32507] Cursor.cursor does not accept cursor names with hyphens

which revolves around h-resize versus h_resize. This is contradicted 
though by the fact that RT-26235 is unresolved in 8 (and even scheduled 
only for 9) while RT-32507 is supposed to be fixed in 8.


The split cursor is missing everywhere: on a splitpane, on the columns 
of a tableview, on custom controls - all inside JFXPanel, of course. I 
tried to work around this by using -fx-cursor: h_resize instead of 
-fx-cursor: h-resize but that helps only outside of a JFXPanel (and 
will probably be broken with FX8). Also tried to work around by setting 
the cursor in code: setCursor(Cursor.H_RESIZE) - but even then only 
other cursors work, not the h/v resize ones.


Any ideas to make this work for FX2 (and maybe even for FX8 considering 
the fix version for RT-26235)?


Rgds
Werner


Re: Checkboxes in a combobox popup

2013-09-16 Thread Werner Lehmann
Never mind. I tried to cut some corners reusing a combobox for a 
checkbox list popup but this got too complicated. I am using a 
ComboBoxBase extending class now.


Unfortunately it is still quite hard to determine a useful listview size 
for the popup. The original combobox uses package private stuff and hard 
casts on the listview's virtual flow. Obviously I cannot do this.


http://i.imgur.com/5rNDCYT.png

Any idea how I can get rid of the horizontal scrollbar on the listview? 
Is there trick how to size the cells so that they always get the 
available horizontal space - but not more?


Rgds
Werner

On 14.09.2013 00:13, Werner Lehmann wrote:

Hi,

I am displaying checkboxes in the popup of a combobox via custom cell
factory. Only problem is that a click on the checkbox actually hides the
popup, even before that checkbox was selected. As I can see, the
combobox skin has a MOUSE_PRESSED event filter which hides the popup.

Current workaround is:
- get the listview from the combobox skin
- set a MOUSE_PRESSED filter on its parent
- in the filter detect a click on a checkbox (sets a flag)
- override combobox.hide, ignore the hide if the flag was set before

The other workaround is to make listview think that the click was on a
scrollbar by adding track to the styleclasses of all checkbox skin
nodes. Then the listview would ignore the click, too.

Both options seem to be... less optimal. Any other idea?

Rgds
Werner


Re: Checkboxes in a combobox popup

2013-09-16 Thread Werner Lehmann

Jasper,

a listview does not seem to use a ScrollPane. That's what its 
virtualization effort is about, using the VirtualFlow instead. Or do you 
mean I should nest the popup listview in a scrollpane?


The MenuButton approach would be completely different and seems to have 
a few disadvantages of its own:


- no virtualization so all those checkboxes would have to be created in 
advance

- no scrolling through as few as 100 items... (and there can be more)
- it is also not really a multiselect control which would allow users to 
quickly toggle some items without having to open the menu again for each 
of them


Werner

On 16.09.2013 16:58, Jasper Potts wrote:

You could try
http://docs.oracle.com/javafx/2/api/javafx/scene/control/ScrollPane.html#setFitToWidth(boolean)
http://docs.oracle.com/javafx/2/api/javafx/scene/control/ScrollPane.html#setFitToWidth%28boolean%29

Or what about using MenuButton with check box menu items?


Checkboxes in a combobox popup

2013-09-13 Thread Werner Lehmann

Hi,

I am displaying checkboxes in the popup of a combobox via custom cell 
factory. Only problem is that a click on the checkbox actually hides the 
popup, even before that checkbox was selected. As I can see, the 
combobox skin has a MOUSE_PRESSED event filter which hides the popup.


Current workaround is:
- get the listview from the combobox skin
- set a MOUSE_PRESSED filter on its parent
- in the filter detect a click on a checkbox (sets a flag)
- override combobox.hide, ignore the hide if the flag was set before

The other workaround is to make listview think that the click was on a 
scrollbar by adding track to the styleclasses of all checkbox skin 
nodes. Then the listview would ignore the click, too.


Both options seem to be... less optimal. Any other idea?

Rgds
Werner


Re: FocusModel too restricted?

2013-09-02 Thread Werner Lehmann

Jonathan,

appreciate your elaborate answer. I arrived at the same conlusion, not 
to use the official FocusModel. There wasn't any hope to get changes 
for 2.2 anyway. It just felt as if it could have been a good match 
because a subset of it would fit perfectly, namely the focused item 
property and methods to focus the next/prev item. I wouldn't have 
supported a pluggable focusmodel anyway, there's not much to gain from that.


In the end I guess my point is that TreeView and TreeTableView would 
have benefitted from the above mentioned subset with item-based focusing 
as well. In a treeview you don't really care about the focused index. I 
think. Especially if it changes everytime something is expanded or 
collapsed. And ListView etc. would extend that simple focusmodel to add 
index-based focus operations.


As to the fake focus inside a listview vs this property sheet 
component: currently I am supporting something like a focused row with 
property name and editor. This row is highlighted and can be 
(fake-)focused even if the property editor is disabled. So it is similar 
to a Listview. Basically, having a fake focus does not mean I cannot 
have a real focus on a property editor, too ;-)


Werner


FocusModel too restricted?

2013-09-01 Thread Werner Lehmann

Hi,

I am trying to use FocusModel in a custom property sheet component - it 
is probably a good idea to reuse as much API as possible and make 
components work similar to each other. However, the focus model makes 
this more difficult than it should be:


1. Why is it index-based? With methods like focusNext and focusPrevious 
it should not really require an ordered, index-based list. The TreeView 
focus model shows how this requires non-trivial extra effort if the data 
model is not similar to a plain list.


2. Why is setFocusedItem package private and final? With this I cannot 
even provide a new method focus(item) because I cannot call 
setFocusedItem internally. My users would have to translate their item 
into an index to be able to focus it. The TableViewFocusModel seems to 
have the same problem - but it is in the same package and can simply 
cheat on package private methods!


To make this still work I'd have to provide index-based access to a 
tree-like data model. And to allow operations like focus(item) I'd have 
to translate the item to an index to call focus(index) instead - 
although I don't even need that index, and providing it is extra effort.


Does it make sense to lift some of these restrictions?
- no index-based requirement
- less final/package-private methods

Similar things can be said about the selection model...

Werner


Exception in one JFXPanel kills other JFXPanels, too

2013-08-13 Thread Werner Lehmann

Hi,

I have noticed the following problem with exception handling and 
multiple JFXPanels (FX 2.2):


1. Two JFXPanels, J1 and J2
2. Throw NPE in layoutChildren of a control inside J1

This would print a stacktrace (see below). Then J2 is blocked: mouse 
clicks have no effect anymore. I think I have seen something similar 
with invalid FXML but did not check again now. On the other hand, if a 
button action-event handler throws an exception everything is fine: 
stacktrace is printed but the JFXPanels stay alive.


What is the deal here? When are exceptions lethal, and what can I do 
to protect against this, preferably without adding a try..catch to each 
layoutChildren (and whereever else this might be needed)...


Werner


java.lang.NullPointerException: kaboom
at 
mint.javafx.scene.layout.designerpane.MintDesignerPane.layoutChildren(MintDesignerPane.java:192)
at javafx.scene.Parent.layout(Parent.java:1018)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:513)
at javafx.scene.Scene.doLayoutPass(Scene.java:484)
at javafx.scene.Scene.access$3900(Scene.java:169)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2199)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
at 
com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
at 
com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at 
com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Unknown Source)




Re: Swing and JavaFX thread merge

2013-08-13 Thread Werner Lehmann

Artem,

we already tested with 7u40 b35 - same thing:


Java Web Start 10.40.2.35
Using JRE version 1.7.0_40-ea-b35 Java HotSpot(TM) 64-Bit Server VM

...

runTest in AWT-EventQueue-2
jfx button click in JavaFX Application Thread
invokeLater from jfx button click in AWT-EventQueue-0
jbutton click in AWT-EventQueue-2
jfx button click in JavaFX Application Thread
invokeLater from jfx button click in AWT-EventQueue-0
jbutton click in AWT-EventQueue-2


Werner

On 13.08.2013 16:31, Artem Ananiev wrote:

Jeff, Werner,

thank you very much for detailed evaluation. The issues you observe may
be related to recent changes in AWT/Swing in 7u25. If my guess is
correct, they should be fixed in the latest 7u40 builds. I know it's not
released yet, but early access builds are available at java.net. Could
you run your apps with 7u40 and check if the problems are gone, please?

Thanks,

Artem


Re: Swing and JavaFX thread merge

2013-08-12 Thread Werner Lehmann

Hi,

coincidentally we were experiencing the exact same problem with the 
combination 7u25, OSX, Webstart. Also, we arrived at pretty much the 
same workaround.


Investigation showed that multiple Swing eventqueues were created in the 
above configuration. This would cause threading issues (NPE), paint 
issues (flicker etc), drag-drop issues.


See below for a testcase: JFrame with a JButton and an fx button. When 
clicked, the former prints its current thread, while the later switches 
to EDT first (invokeLater) and then also prints the thread. On Windows, 
this turns out to be the same thread as expected. On WebStart 7u25 OSX 
we are getting different AWT-EventQueue-X threads.


Werner


public class TestSwingEDT extends JFrame{

  public static void main(final String[] args){
SwingUtilities.invokeLater(new Runnable() {
  @Override
  public void run() {
new TestSwingEDT().runTest(args);
  }
});
  }

  private void runTest(String[] args){

System.out.println(runTest in  + Thread.currentThread().getName());

this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300, 200);

final JFXPanel jfxPanel = new JFXPanel();
Platform.runLater(new Runnable(){
  @Override
  public void run() {
Button btn = new Button(click me);
btn.onActionProperty().set(new EventHandlerActionEvent() {
  @Override public void handle(ActionEvent ae) {
System.out.println(jfx button click in  + 
Thread.currentThread().getName());
SwingUtilities.invokeLater(new Runnable() {
  @Override public void run() {
System.out.println(invokeLater from jfx button click in  + 
Thread.currentThread().getName());
  }
});
  }
});
HBox hbox = new HBox();
hbox.getChildren().add(btn);
jfxPanel.setScene(new Scene(hbox));
  }
});

JButton jbutton = new JButton(click me);
jbutton.addActionListener(new ActionListener() {
  @Override public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println(jbutton click in  + 
Thread.currentThread().getName());
  }
});

JPanel rootPanel = new JPanel();
rootPanel.add(jbutton);

this.getContentPane().add(jfxPanel, BorderLayout.NORTH);
this.getContentPane().add(rootPanel, BorderLayout.CENTER);

this.setVisible(true);

Platform.runLater(new Runnable(){
  @Override
  public void run() {
SwingUtilities.invokeLater(new Runnable() {
  @Override
  public void run() {
System.out.println(invokeLater in Platform.runLater in  + 
Thread.currentThread().getName());
  }
});
  }
});

  }
}


Re: Missed pulse?

2013-07-31 Thread Werner Lehmann
Easy trap with invalidation listeners. If you don't get the property 
value after invalidation, the property remains invalidated and 
subsequent changes won't trigger another invalidation. To fix this, 
simply get the value (for nothing), or switch to change listeners...


You probably know this by now but maybe somebody else didn't...

Werner

On 31.07.2013 10:47, Diego Cirujano-Cuesta wrote:

One of the problems was, I was using invalidation listeners and I
wasn't getting always the value


Re: Can JavaFX do CAD?

2013-07-29 Thread Werner Lehmann
Wouldn't this be covered by Shape.union? Obviously it depends on how 
union is implemented under the sheets, but it seems to me as if there 
was an opportunity to optimize it like that.


Werner

On 24.07.2013 21:06, Richard Bair wrote:

I filed an RFE a little while ago for a LineGroup or something like
that (I don't remember what I called it). But basically it is
supposed to be a Shape which is just a bunch of independent lines.
You could draw them much like a path with line-to's, but instead of
generating a single path. But you'd still have problems when it comes
to performance if we end up having to send down multiple textures for
lines of different orientations / lengths.


Re: Can JavaFX do CAD?

2013-07-29 Thread Werner Lehmann
Good questions. I've had experience with some of these, building a GUI 
designer. At this stage customers will use it to build input forms. 
Later it is supposed to grow into sort of a report designer.


The core is a custom component containing a ScrollPane containing a 
content pane. And that pane has several transparent layers spanning the 
whole (scrolled) content area. There are layers for a grid, the content 
items, selection, decoration, and hints. There've been rough edges and 
workarounds but I am quite happy with the result. This would have been 
more difficult in Swing.


On 24.07.2013 01:21, Daniel Zwolenski wrote:

- How best to represent large numbers of complex shapes efficiently, and when 
to add shapes to the scene (add all and let jfx clip, or manually work out what 
should be showing, etc)


Fortunately my scenes are usually not that complex. A few 10k nodes can 
be expected.



- How best to handle font scaling and image scaling when rendered in a zoomed 
in/out viewport


I have not looked into this. I guess it would be relevant for us to 
support touch.



- How best to do panning and zooming with dynamic level of detail


Dynamic level of detail is another important one. We may need to address 
this for a different component, showing tons of data which can be zoomed 
in/out.



- How best to do the top level display in terms of panes vs regions vs canvas, 
vs whatever, how to manage overlays and layers (sharing same coordinate space, 
etc)
- How best to do picking, mouse overs, dragging across the 'display'
- How best to do infinite or dynamic  bounds so you can add and move shapes and 
the scrolling adjusts accordingly.


As described above, several pane/region based layers in a scrollpane 
work satisfactorily for us. Bounds are already dynamic, simply resize 
the ScrollPane content node. Mouse picking, dragging, etc. works with 
mouse event filters on the scrolled content node.


Werner


Re: Thread checks in Glass

2013-07-22 Thread Werner Lehmann

Seems as if the ticket isn't public...

On 22.07.2013 11:06, Petr Pchelko wrote:

You can follow progress inhttps://javafx-jira.kenai.com/browse/RT-26891


Re: Validate cell, or request a cell update

2013-07-09 Thread Werner Lehmann
Ok - this means that in Cell.updateItem I would have to add a (weak?) 
listener to the item's state property. If the cell is reused for another 
item I would have to remove the old listener first. My only concern is 
that this will be done a lot when scrolling through the list. Thanks...



If the data item isn't observable, then you need a way to manually poke it.


Basically I can only talk from the Cell to the item, not vice versa. 
Unless I would store the cell reference in the item, not a good idea. 
So if item state changes, it must be observable from the cell, in some way.


Werner

On 09.07.2013 19:28, Richard Bair wrote:

I think this is different. The idea was that you would bind state on
the cell to the item it is representing, so that it is automatically
updated when needed and then there is no need to manually poke it. If
the data item isn't observable, then you need a way to manually poke
it.


Re: Experience with piecewise migration Swing - JFX

2013-06-17 Thread Werner Lehmann
In addition to what has been said before, you could check Jira for 
keywords jfxpanel and/or swing. Just today we had another Mac-only 
problem. Apparently AWT is not as thread-safe on Mac as it is on 
Windows, resulting in deadlocks in native AWT code (which currently is a 
guess, not confirmed, RT-31124).


Another relatively minor issue: if you have to use multiple JFXPanels on 
one Swing window the code can get quite complicated because of the 
frequent context switches between the GUI threads. Currently I am adding 
a note to the javadoc of UI methods to state which thread it is supposed 
to be called in.


Even with one JFXPanel and other Swing UI on the same window, you'll get 
a problem with tab focus movement: the jfxpanel would happily receive 
focus but then users cannot tab out of the jfxpanel.


Also seen today: after closing the last JFXPanel while the Swing 
application continues, FX would exit the platform (not the VM) and you 
cannot use another JFXPanel. There is probably some workaround available.


And just in case it has not been said before: you cannot have a Stage on 
top of a JFrame (modal or not). This forces you to wrap a JFXPanel into 
a JDialog.


I have also seen a performance problem. Try an indeterminate progressbar 
in a JFXPanel. The progressbar width directly correlates with CPU usage. 
With ~400px width I get about 20% CPU usage (almost one core). This is 
probably caused by constant pixel shifting to AWT.


Werner

On 14.06.2013 17:08, Robert Krüger wrote:

What are the hidden problems one should be
aware of (other than having 2 UI threads).




Re: NullPointer in BaseGraphics.drawTextureVO

2013-06-11 Thread Werner Lehmann

Is this the same as SwingFXUtils.toFXImage?

On 11.06.2013 14:27, Daniel Zwolenski wrote:

 BufferedImage buffImage = AWTImageConverter.toBufferedImage(image);
 jfxImage = javafx.scene.image.Image.impl_fromExternalImage(buffImage);
 previewView.setImage(jfxImage);


Re: ScrollPane.prefViewportWidth == computed size?

2013-06-03 Thread Werner Lehmann

Hi Richard,

thanks for the quick reply. FYI, I am currently using a hardcoded value 
with some extra space, hopefully sufficient for all platforms.


On 03.06.2013 20:57, Richard Bair wrote:

I think calling it a bug would be fair, and this approach should work.


I'll create a ticket later.


Hmmm. I guess fitToWidth doesn't work for you because you want the
content to dictate the size of the scroll pane, and not the other way
around? Maybe a combination of this and a subclass to work around the
issue you are seeing?


Exactly. fitToWidth removes the horizontal scrollbar but abbreviates the 
label text (...). The suggested subclass approach does not work 
because prefWidth() is final in Control. Is there any event I could 
listen for to update the prefWidth? I tried onSceneChange but that 
seems to be too early as prefWidth(-1) returns 0.0 then.



Or maybe the ScrollPane, when fitToWidth is true, automatically
adjusts its pref width to match that of its content? That would seem
to be the right thing to do in this case, but I don't know that it
does (or that it makes sense in all cases?).


ScrollPane.fitToWidth resizes its content (if resizable) to its viewport 
width. Does nothing if content is not resizable, and does not seem to 
change ScrollPane.prefWidth. I'd say fit-to-width could mean both: 
fit content to viewport width and fit viewport width to content. The 
former is already implemented, of course. No horizontal scrollbar in 
either case.



So it seems to me that there are at least 2 different ways we could
go about supporting this specific use case, one seems like a
straightforward thing (let -1 have meaning for prefViewportWidth) and
one is the result of a perhaps questionable interpretation
(fitToWidth=true changes the way we compute the prefWidth of the
ScrollPane). Both seem reasonable ways to have tried to use the
control and both yield unexpected results it sounds like.


The binding was not really obvious to me but eventually I arrived here 
and it would be nice to have this working. Additional API would make 
this easier to find but it might be hard to come up with something which 
makes sense in the API and does not change or conflict with existing API.


Werner