I love deadlines, I love the whooshing sound they make as they fly by...
Ciaran Mooney wrote:
A class MyVolorChooser has a private member sliderColor. Default value is set to black in the constructor.
A inner class handles the construction of a new color via user input from JSLiders. I then set slideColor value to this new colour via a setMethod in the outer class.
Problem is a instance of the outerClass uses the outerClass method getColor which always returns the value from the constructor (black), and not the new value it has been assigned via inner event handier class?
Any ideas?
I love deadlines, I love the whooshing sound they make as they fly by...
I love deadlines, I love the whooshing sound they make as they fly by...
I love deadlines, I love the whooshing sound they make as they fly by...
So as suggested I controlled obj creation using a singleton class of MyColorChooser4 to ensure two objects are sharing the same colour....
Object 1 is created in the DrawInternalFrame and rendered onto the JInternalFrame.
Object 2 is in Class ShapePanel where shape type and color is selected.
But when I look in the class itself I see the color has changed according to the JSlider input......so somehow a instance of the class has none of the values that the class has in its current state.....
I love deadlines, I love the whooshing sound they make as they fly by...
Ciaran Mooney wrote:
PS @Surlac how does one log the threads accessing the setter?
surlac surlacovich wrote:...
1. I thought i had created the one instance that coould be used in different classes:
..but ended up with same problem where they appeared to be actually separate instances as opposed to the same instance used in separate classes.
2. If I were to create a single instance of a class and pass the ref of the instance to objects that need it, where would one create the instance so as it could be used in a number of different classes?
surlac surlacovich wrote:
Tony, are you sure Swing/AWT doesn't create instances by itself?
surlac surlacovich wrote:
Dunno, but it looks like.
Tony Docherty wrote:
surlac surlacovich wrote:
Dunno, but it looks like.
Debugging is a difficult process and it is all to easy to jump to a conclusion and then try to make the facts fit. Debugging is an iterative process you need to gather lots of evidence, look at that evidence and think of what circumstances might cause those results. Then you gather more evidence to prove/disprove those ideas and so on.
I love deadlines, I love the whooshing sound they make as they fly by...
Ciaran Mooney wrote:What is the best way to upload, as java files or a jar file?
Tony Docherty wrote:
The best thing to do is to produce an SSCCE and post the code here.
surlac surlacovich wrote:
Either topic-starter posts the whole project or narrow down the whole source code (truncating all unnecessary code) till the problem exists but code-base is minimal.
surlac surlacovich wrote:Also, I personally don't know how to source code posted in this thread and what dependencies I will need to add to make it even compile.
surlac surlacovich wrote:So the project files will be very helpful.
Tony Docherty wrote:
Posting code is easy. You post source code by cutting and pasting the code into the editor, highlighting it and clicking on the 'code' button.
There are no dependencies to worry about in an SSCCE as it is self contained.
Tony Docherty wrote:
surlac surlacovich wrote:So the project files will be very helpful.
It is rarely, if ever, true that seeing the whole project is better than seeing an SSCCE as when looking at the whole project you have to spend an amount of time working out which code is not relevant before you can even look for the problem.
I love deadlines, I love the whooshing sound they make as they fly by...
It's just a flesh wound! Or a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|