how do u display text on the applet when a button is pressed?
ok, so i have buttons on the screen and when it is clicked the action method is called. How do i get it to print text on the java applet when it is clicked? When i try to say g.drawString("You Clicked This Button"); it says that it cant resolve g or whatever. i have g in my paint method though. So how do i get it to draw text on the java applet after the button is clicked.
You call repaint() when the button is clicked, and in the paint method you
draw your text using the Graphics pointer that is passed as a parameter (g)
to that method.
Note: the Graphics g in paint/update is the pointer to the display's graphical
context, if you do rapid drawing (animations) you will get flickering if you
use it as it is. To avoid that you will have to implement double buffering.
But, for displaying a simple line of text at a button click, this wont have any
Last edited by sjalle; 06-08-2005 at 08:38 AM.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center