I am to write a program that uses the paintComponent method to draw the current value of a JSlider on subclass of JPanel. in addition provide JTextField where specific value can be entered. JTextField should display the current value of the JSlider at all times. JLabel should be used to identify the JTextField. the JSlider methods setValue and getValue should be used.
The code as posted can't even be compiled. In this code there are several closing brackets missing. That could be a problem of this forum. Repost the code, but this time use the java tag as shown on the right side of the input field.
Also post the code for OvalPanel, since I don't know what myPanel.setDiameter(diameterSlider.getValue()) does. I ca nonly assume that It filles a Textfield.
Now to some points I noticed: 1. You need to override the method
void stateChanged(ChangeEvent e)
in your ChangeListener. If you don't it won't do anything.
2. If this IS the code as you wrote it (and it's not the fault of the forum) then first you should put eerything into the constructor that belongs into it. You put a closing bracket after the "fillOval" line. I'm sure that does not belong there. I suppose it belongs after setVisible(true), right? 2.1 addChangelistener must be inside the constructor.
3. getPreferredSize and getMinimumSize should not be inside the changelistener.
4. I don't know if setDiameter belongs to the changelistener, but I suppose not.
All of this points except point 1 are related to missing or additional brackets. If it's not the forums fault, you should pay more attention there. Brackets are the non-plus-ultra in programming. They mark what belongs together, so they are the first thing to look at.
Hint: Instead of asking "what is wrong here?" you should give some more informations: are there compile errors (where), does a method not get called or returns the wrong value or whatever. Also a code without documentation is difficult to read for someone else than the author. If you just don't know what to write, at least post the output you get from the compiler or running the program.