Hello geork
To use anything in Java, you must declare it before you use it. I modified your code and it works now:
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
public class GameScreen1 extends JFrame implements ActionListener{
protected int num = 5; // I moved this above the definition of the score JLabel.
protected JLabel label8 = new JLabel("hi! this is your score!");
protected JLabel label9 = new JLabel("feel free to look at your score any time");
protected JLabel score = new JLabel((new Integer(num)).toString());
protected JButton l = new JButton("ok");
public GameScreen1(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
setLayout(new FlowLayout()) ;
add(label8);
add(label9);
add(score);
score.setEnabled(false);
add(l);
l.addActionListener(this);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
l.setEnabled(false);
// I removed the "new GameChoose();" since I don't have that class
}
}
And using the above code:
Originally Posted by geork
to be specific i typed:
class Success extends GameScreen1 {
String setText(){
return score +1;
}
}
and it said i wasn't allowed to use a simple +1, what should i do?
Score is a JLabel object and not an integer, so you cannot add integer values to it. However, num is an integer, change that and then update the JLabel. Also, a sub class cannot be less accessible than its parent.
public class Success extends GameScreen1 {
public void incrementScore(){
this.num += 1;
updateLabel();
}
protected void updateLabel(){
score.setText(new Integer(num)).toString());
}
}
I'm not sure what you are trying to do, but I can help with the Java.

Also, please use code tags when you post your code.

To use code tags:
[ CODE] //My code here [ /CODE], but without spaces in the tags. Please read the FAQ.
I hope this helps.
