I intend to do the following:
After an application (or an applet in my case) is already displayed on the screen I want to draw a String on a Button in a different color when this Button is clicked.
The text on the Button shall be displayed in green when the use of the Button is OK and it should be appear in red when the applet is busy and is doing this action right now.
The main question is:
How can I use painting methods (Graphics methods) outside the paint()-method.
I tried the following several times:
Button button = new Button("Show");
Graphics gc = button.getGraphics(); // this works well
FontMetrics fm = gc.getFontMetrics(gc.getFont()); // OK
top+5 /*any y-point*/);
}// end anyMethod
To solve this problem more generally:
How can I paint (lines, text, shapes, ...) without invoking the paint method?
I mean, sometimes you want to draw something after you have displayed something else without redrawing this because that doesn't change!
Of course, what is already displayed shall be displayed without changing!
I am still currently using JDK 1.0, however I am interested in the solution for JDK 1.1, too, if it differs from the "1.0-solution".