With the windowsbuilder i've created a little gui in eclipse. And in the action event of a button ive written this code:
progressBar.setValue(0);
but that does not work. "progressBar cannot be resolved" Please Help! ps: i'm new to Java EDIT:
JButton allButton = new JButton("Klick Mich!");
allButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
progress1.setValue(50);
main.infoBox("Hallo Welt!", "Hallo Welt!");
}
});
EDIT2:
JProgressBar progress1 = new JProgressBar();
progress1.setStringPainted(true);
progress1.setBounds(20, 124, 408, 23);
frame.getContentPane().add(progress1);
}
EDIT3 [COMPLETE CODE] http://pastebin.com/68z1Mpen
you have created jprogressbar after you access it.you have to create before access
like this
JProgressBar progress1 = new JProgressBar();
JButton allButton = new JButton("Klick Mich!");
allButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
progress1.setValue(50);
main.infoBox("Hallo Welt!", "Hallo Welt!");
}
});
when you call
progress1.setValue(50);
progress1
isn't declared .so that's why you are getting a error