This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Pages: 1 - Last Post: 04-Sep-2017 20:40 Last Post By: davidekholm
jGromit

Posts: 32,924
Registered: 01/31/06
JSpinner issue in custom UI
Posted: 04-Sep-2017 16:04
 
  Click to reply to this thread Reply
I've run into an odd little problem in a custom UI. I suspect there's no solution, but thought I'd toss it out there. A minor issue, to be sure.

The quick demo: choose Gromit, and create a project with a couple of images in it. Now go into edit mode on the first image, and open the little Gromit panel on the right. Enter something (anything) in the Video host URL field. This will enable the Width and Height spinners.

Change the value for Width by using the spinner arrows. Now hover on the image and click the arrow icon to go to the next image, then return to the first image. Your change to Width should be shown. So far, so good.

But now change the value for Width by manually entering a value in that field. But without hitting Enter or Tab, move to the next image for editing, then back again. Your change to the Width field hasn't been registered.

I've tried adding a FocusListener() to the spinners, and also a StateMonitor() that listens for any change, each of them forcing a saveUI(). No luck. I can feel what's happening - until the user leaves that spinner field, his input hasn't been validated by the spinner, so it hasn't registered. After all, he could enter abcd, which would not be a valid value.

Any bright ideas?
davidekholm

Posts: 21,292
Registered: 10/18/02
Re: JSpinner issue in custom UI
Posted: 04-Sep-2017 17:38   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I believe I've fixed this with the following code added to JCustomPanel.saveUI()
        Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
        if (focusOwner instanceof JFormattedTextField) {
            JFormattedTextField tf = (JFormattedTextField)focusOwner;
            try {
                tf.commitEdit();
            } catch (ParseException ex) {
            }
        }
Do a core update to try it out!
jGromit

Posts: 32,924
Registered: 01/31/06
Re: JSpinner issue in custom UI
Posted: 04-Sep-2017 18:05   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
It looks like that did the trick!

No need for any forced saveUI() calls, either, at least not in Gromit. I still have to use them in Matrix because that entire custom UI is in a separate popup, where the jAlbum core isn't controlling things as tightly. But simple StateMonitor()'s take care of it pretty well there.

This is one of those weird little things that a user would almost never encounter. I only found it because I was changing some video frame bounds in one of my demo albums, and my changes were mysteriously vanishing!
davidekholm

Posts: 21,292
Registered: 10/18/02
Re: JSpinner issue in custom UI
Posted: 04-Sep-2017 20:40   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Great!
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums