So I have this class:
public class setting{
JLabel label;
Component main;
JButton set, reset;
setting(String s, Component b){
this.label = new JLabel(s);
this.main = b;
this.set = new JButton("Set");
this.reset = new JButton("Reset");
}
public void add(JPanel b) {
b.add(this.label);
b.add(this.main);
b.add(this.set);
b.add(this.reset);
}
}
How would I be able to access this.main 's information? For example:
JSlider speed = new JSlider(0, 80); speed.setValue(0);
setting speedSett = new setting("speed", speed);
speedSett.main.getValue(); //This doesn't work
Is there anyway to access the information inside of the setting class the way I have this setup? I would like this class to accept different types of components, so simply setting it to JSlider won't do it for me. Thank you in advance.