AhFai Chan

Ranch Hand
+ Follow
since May 10, 2004
AhFai likes ...
Android Eclipse IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
24
Given in last 30 days
5
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by AhFai Chan

@Knute Snortum  why do we need the ViewMaker.class???

My codes do bring back Scene2 BUT only one control is showing in the scene, rather than all od them. The rootNode for Scene2 is a GridPane, and the widgets for the node are laid out like this:


When Scene2 is displayed, it shows only tdP in the scene.

Why doesn't Scene2 display the whole scene?

P.S. It doesn't throw an error either, in some ways its better if there are error messages, but now, it just display one control i.e. the TextBox for property tax.
13 hours ago
Who pays for the Oracle JRE, the developer or the end-user?
Surely the end-user has the choice to use another JRE !?!
1 day ago
It's about binding and its more to help me understand the way FX works rather then actual codings.

As the codes are, Scene2 does not display the bound value for the property tax bill.

As you can see, I have 3 bills, property tax, utility and water. I want to display the final value for each of them in Scene2. For that to happen I think I need a listener for observable values, from old to new. I am just trying to figure out how to inject a listerner for each bill into Scene2, I think I need 3 listeners.

Then I will try using an observable array to pass the same values instead of using bindings.

If I want to pass values from one scene to anther, what's the difference between using an observable array and binding variables?

1 day ago
Okay, based on invocation target exception, I traced the error back to Scene2.
After commenting out the spurious lines, the second scene gets displayed.



I think they were from auto-completion when I was writing the codes, happens regularly with auto-complete.

Now I have another question about binding in the codes. DO you want me to start another thread?
1 day ago
I brought the codes back to the form in the posting from above...
I am now getting an "InvocationTargetException"

1 day ago
I am trying to understand how FX does things, here are several pieces of codes:

QUESTION: How to I get to Scene2 from DataMainApp.class ??



MultisceneDemo is the 1st scene to be displayed, when I click on the button, it should display the 2nd scene i.e. Scene2 along with the bound values.
But my codes do not take us to Scene2...



This is the Controller.class, its single handlePressButton(Action event) method is invoked by MultisceneDemo (see above)



This is the second scene, to be displayed when I click on the button in the first scene.
The objective is to see the bound values displayed here. Later on I will be changing values in scene 1 with more codes




Some FX-styled getters-setters





There is not much to the logic, but I can't seem to get FX working
1 day ago
Gotcha
Onto next FX challenge...
2 weeks ago
QUESTION:
===========

Why does observableArrayList put square brackets around values ?
I can subsrting into them to get rid of them, BUT, it shouldn't be so.

Also, I have this error message when I tried to cast ObservableList<String> to String just so I can set the value.
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: com.sun.javafx.collections.ObservableListWrapper cannot be cast to javafx.beans.property.SimpleStringProperty

DETAIL
===========

When overlaying my old Java codes with JavaFX, I found it necessary to use ObservableArrayList throughout all scenes to access the data retrieved from cloud, lke this:


The data coming back from the db are in JSON string which I can easily unpack. For example
userName = Arthur Chan

But when I access the ObservableList<String> userName from annother scene or class, it has square brackets around them, like this:
userName = [Arthur Chan]

I can get rid of the brackets, but I shouldn't have to b/c there's no reason why JavaFX should wrap in brackets..


3 weeks ago
About static class: it is my own development environment.

About not using lambda: its difficult to debug, Eclipse cannot step through the lambdas step by step and the stack trace is difficult to follow. Also, I am not following the flow of the code  when they are hidden from me.
I don't think books should use lambdas, authors can point to the advantage, being less typing, and give examples, but for us to follow the flow of the logic, it's best not to use lambdas.

Thanks, I think I have got that running, I needed to get a ListView with FX.Collections.getObservableArrayList();

One last thing b/4 signing off on this one:
If you are trying out code samples in book, pay particular attention to the ReST APIs the authors are using.
I have imported java-json.jar into \lib folder in most of my apps, but this particular book used jsonp_1.1_api.zip  which you can download here:
https://jcp.org/aboutJava/communityprocess/pr/jsr374/index.html

saves you hours of head-scratching...

4 weeks ago
Thanks for following up.

I have only one private static class using static fields and methods containing data about the user who has logged in. Many of the other classes store data from the cloud.

There's a chapter that talks about FX with enterprise modules, can you help me expand the Lambda expression in the codes:
4 weeks ago
I think I know what you mean. I'd like to try out a few things myself first as this is the first time I am using FX
From the downloaded data, I am trying to create an object, like this:

See whether I can retrieve as a static object, like this:


Thank-you for following up.
I am trying to understand the constructs "model", "view" and "collectors" and where and how ObservableList fits into them
The book is no helping much in clarifying them.

1 month ago
Requirements
*  My system is mainly in legacy Java, it has a 3-GL touch-and-feel to it and urgently needs to have a modern UI and graphs added to it.
*  It accesses a cloud mySQL, updates the db or download data from it using sprocs.
*  The data can be hundreds of records displayed line-by-line, they should be displayed in table format
*  They must also be graphed in XY-, bar- or pie-charts, or combinations thereof

Using helpful inputs from you, I have replaced the 3GL logon with FX, replaced the 3GL menu with the file-menu and submenu and I have no further issues with scenes, nodes and nodes-in-nodes. The UI begins to look friendly.

Problem Statement
* I can download the data and put them into a JSON array, and from there to any convenient array, but as of today, I still cannot display the downloaded data in FX's table views, text fields etc.
* Using the codes upstairs, in the first posting, how would I display the values for chassisColor and mobilePhone in FX? Using Java would be simple...

Am doing research using APress'es "Pro JavaFX9" by Vox, Chin, Gao et al.


I am not coming up to speed in FX as fast as I would like




1 month ago
In Java apps, whenever I use a getter-setter to "store" a set of data from the db, I simply create a class to do that and make a call to the setters. Then the set of data would be available to all other classes in the same package.
In JavaFX it seems I have to use bindings and properties, centered around views, controllers and models classes. All new to me.
I have not been able to get that working yet, still reading up on bindings and properties in the APress book.  
1 month ago
QUESTION: How to access the legacy Java  getters from JavafX?

I have several legacy getters and setters from old codes that I wrote. Now I am using JavaFX and I cannot access these same getters.
In our example here, the setters are in a class called "Owner" and the data comes from a remote db, code snippet follows...


My old Getter-Setter class is typical for such. In any of the old apps, I would get the color with a simple
pulic String getChassisColor() { return chassisColor;}
This does not work anymore.

I am thumping through APress "Pro JavaFX 9" 4th edition by many authors, ppg 112-115 seem to point the way using JavaFX Beans, but seems very complex...

Is there something else I have not read up on in JavaFX? Some pointers to documentation and examples appreciated.
1 month ago
opps

The trick with injecting a stage is really cool.

If you should write an indepth book on JavaFX
1 month ago