File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Problem with repaint() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with repaint()" Watch "Problem with repaint()" New topic

Problem with repaint()

Clay Adkerson

Joined: Mar 16, 2005
Posts: 27
i have 3 buttons: b1,b2,b3. What im trying to do is is when you click on the button it will use drawString to write what button you clicked. Im using AWT .

Here is the code i have so far.

The problem is that i cant figure out how to get it to use drawString. I tried using repaint() but i dont think i did it correctly. Im am a newb at this. I put in the paint method-> if(source == *button name here*) and then typing the g.drawString and i put repaint() in actionPerformed but it wouldnt work. Compiled correctly though. Hope you understand what im asking. Thanks ahead,
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Moving to Swing/AWT...

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Clay Adkerson

Joined: Mar 16, 2005
Posts: 27
Thanks. This helps some. I'll look it over and update my code. What i have to do is create an applet showing what we learned in class. I have 3 buttons(Java, Html, Unix) that when you click will print text on the screen giving examples and such of each. That class that i posted was just a test thing to try to get it to work.
I agree. Here's the link:
subject: Problem with repaint()
It's not a secret anymore!