-
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
side effects.
Last edited by sjalle; 06-08-2005 at 08:38 AM.
eschew obfuscation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks