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
2
Received in last 30 days
2
Total given
30
Given in last 30 days
6
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by AhFai Chan

Thank-you all, for the explanations on the pros and cons of MVC.
This is a feel-good piece
1 week ago
Ohhh
I had a few checked without filling out the methods in the Controller when I was testing.
I did very much want to edit the ListView items and upload back to the cloud later.
I am not going to work this weekend.
Thank-you.
1 week ago
QUESTION: How do I get ListView to display multiple selections when using Scene Builder in Eclipse??

I am using Scene Builder in Eclipse to help me implement MVC and running into problems with Scene Builder
Please see .jpg underneath all this for a visual...

Here is the Controller code, I have been trying out variations, hence the "comment-out" bits...


The code for Main()


The FXMLDocument
1 week ago
@Paul Clapham
Thanks, you have made the whole architecture more palatable for me. I am getting used to it and I will really just do what works... even if the coding does not strictly conform to the architecture.
1 week ago
Okay, I found out how to initialize the ComboBox:


Now I need to figure out how to get eclipse Scene Builder to do   MultipleSelectionModel<String>.

Would be very nice to know the WHY's and WHEREFOR's though...

ANSWER: Use a ListView instead of a ComboBox and set the selection model to(SelectionMode.MULTIPLE)
1 week ago
QUESTION:  How to initialize ComboBox using Scene Builder in Eclipse ???

ANSWER: like this


Also, ComboBox does not support multiple selection model.

Instead, I used a ListView.
1 week ago
Nothing, they just canned it.
I've been working with it on and off for the last weeks and am getting used to its complexity, so I'll stick with it.
1 week ago
When using JavaFX, I have been applying the MVC architecture but getting some online advice that MVC is "dead" and not to use it.

Working thru books and when looking up Oracle's demos and samples for guidance, the codes that used to be in Controller are now together with the Modal and View i.e. the user interacts with the GUI and the setOnAction bits are all in the same class

In eclipse, with the e(fx)lipse and Scene Builder add-ons, the MVC architecture is still used and I can drag-and-drop with Scene Builder to create the .fxml document

So use MVC or not use MVC?

If not, then use what?
2 weeks ago
@Zemiak
Thanks, it's much clearer now what the "::" does.
After I got the hang of what "->" actually does...
And it's actually in my highlighted text at the top... so, reconfirmed.
3 weeks ago
"Learn JavaFX8" by Kishori Sharan
and
"Pro JavaFX 9" by Vos, Chin, Gao et al
both published by APress
I got them from Amazon

Also, I  use this primer
"Introducing JavaFX 8 Programming" by Schildt
published by Oracle Press
I got this one from Barnes and Noble, NYC


SOmetimes, I mix and match from various books, so direct attribution could be quite difficult and most of the Java I learn are from books, often from library books or online researches,  Oracle, Javaranch etc
I am actually not a Java developer or careerist, I just thought Java was enormously useful in a project I am doing and its better than writing functional spec, until I just hit a brick wall with FX and various MVP architectures.
Thanks for the pointers.
3 weeks ago
Yes, that's the code from one of the books. Mind you, I am reading up on the differences betw MVC, MVP, AM-MVC and variations thereof, so I am confused, probably from reading 3 books concurrently.

But after your explanation, comparing it to real life, it makes sense to me now.

Thanks ...
3 weeks ago
When, under what circumstances, would you use "atomic"?
Reading this book in front of me, I assume the author is talking about a multi-threaded environment and only one thread can execute the increment at a time, hence in my mind "locked" until the operation is done.
Is this the reason for using "atomic"?

In a multi-thread environment, just instantiate another instance of the class, don't use static. That way, we don't have to use "atomic"

Am I missing the point?
3 weeks ago
QUESTION: WHat does it do and what does it hope to achieve?

QUESTION: What is the "expected value" in this case? What is the code expecting, true or false, 0 or 1?

In database terms,  I think (meaning I am not sure) it might have something to do with LOCKING the personSequence counter for exclusive RWED until the operation is finished and released from the exclusive lock. This means it is in a multi-threaded environment and is dealing with concurrency. How far off am I?

3 weeks ago
I was following the tutorial here:
https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html

QUESTION: Am I to understand that -> and :: are the same?

Notice that the interface Comparator is a functional interface. Therefore, you could use a lambda expression instead of defining and then creating a new instance of a class that implements Comparator:

Arrays.sort(rosterAsArray,
   (Person a, Person b) -> {
       return a.getBirthday().compareTo(b.getBirthday());
   }
);

However, this method to compare the birth dates of two Person instances already exists as Person.compareByAge. You can invoke this method instead in the body of the lambda expression:

Arrays.sort(rosterAsArray,
   (a, b) -> Person.compareByAge(a, b)
);

Because this lambda expression invokes an existing method, you can use a method reference instead of a lambda expression:

Arrays.sort(rosterAsArray, Person::compareByAge);

The method reference Person::compareByAge is semantically the same as the lambda expression (a, b) -> Person.compareByAge(a, b).
Each has the following characteristics:
   Its formal parameter list is copied from Comparator<Person>.compare, which is (Person, Person).
   Its body calls the method Person.compareByAge.

I am posting the codes from the Tute for your convenience:



Here is the Person class, which looks like the Model to me (something I picked up reading about MVC and MVP and AM-MVC, all very confusing). I can see my collection of classes expanding by a factor of 3.




QUESTION:  Can you write this code using a lambda to replace the method reference please?


3 weeks ago

Tim Holloway wrote:Except that that isn't Java, it's C++!
Java doesn't have a "->" operator. Or for that matter, as far as I can recall, a "::" one.



That's what I said too, earlier on somewhere else, use an anonymous inner class instead of lambda
It's clear what I want to do and what I expect out of it. How do you put multiple statements in a lambda? Oh yeah, write another class and point the lambda to it.
Big whinge...
3 weeks ago