I am writing a simple minesweeper game and now it works, but I am working on fairly detailed details, for example, so that each number is different in color.
I continue to encounter errors when I try to set the text color on JButton . I can easily change the text and background, but not the color of the text.
The part that keeps everything spoiled:
total = Integer.toString(count); jb.setText(total); if(count == 1) jb.setTextColor(Color.blue); if(count == 2) jb.setTextColor(Color.green); if(count == 3) jb.setTextColor(Color.red);
For some reason my mistake is:
MS.java:109: error: cannot find symbol jb.setTextColor(Color.blue); ^ symbol: method setTextColor(Color) location: variable jb of type JButton MS.java:112: error: cannot find symbol jb.setTextColor(Color.green); ^ symbol: method setTextColor(Color) location: variable jb of type JButton MS.java:114: error: cannot find symbol jb.setTextColor(Color.red); ^ symbol: method setTextColor(Color) location: variable jb of type JButton 3 errors Process javac exited with code 1
This happens whenever I try to compile, but when I change it to say setBackgroundColor instead of setTextColor , it works fine.
source share