Re: Design Pattern Question
? I am a big confused here ? Doesn't the JSlider have an event? Can't you just use it?
- ØØ -
Re: Design Pattern Question
Hey, this is exaclty what I'm doing. I did something with an interest rate:
int value = interestRateSlider.getValue();
int rate = (double)(1+(.01*value));
First of all, I made my slider go from like 0 to 500 so that I would have plenty of room for decimals and stuff like that.
I got the value from the slider, then created a double out of it with 2 decimal places, and that was it. After that, mortgages were calculated and points were added to arraylists and then it was off to the canvas class to repaint.
Re: Design Pattern Question
Quote:
Posted by NoteMe
? I am a big confused here ? Doesn't the JSlider have an event? Can't you just use it?
What i want to do is have a JSlider at the south portion of a JFrame and a JSlider to the east each with a line comming out spanning across a Canvas. So the lines are always going to be intersecting.
I guess what i need is two classes that extend JSlider and implement a ChangeListener interface and ask for a repaint when a ChangeEvent is fired off. The problem is that JSlider has a getValue() method and to draw a line i need to use g.drawLine(int x1, int y1, int x2, int y2). Also if the drawLine() method is shared by both JSlider classes how does the paint method within my class that extends canvas know which JSlider is being slid?