Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Painting a frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Painting a frame" Watch "Painting a frame" New topic

Painting a frame

Howard Ralston
Ranch Hand

Joined: Jun 25, 2001
Posts: 105
Hi guys,
I'm having another problem doing basic coding. What I am trying to do is make a frame with a button which when pushed will create a "balloon" which travels from the bottom of the frame to the top. Every time you push the button, you get a new balloon. I am trying to do this using threads in the makeBalloons class, but I get an error saying that there is no method update() in class makeBalloons. I could figure out how to do this in an applet, but I cannot do it in a frame. Can anybody help me out here?
Thanks in advance,
import java.awt.*;
import java.awt.event.*;
public class LooseBall extends Frame implements ActionListener{
Panel p;
Canvas c1;
Button push;
Label label;
super("Floating Ballons");

p = new Panel();
c1 = new Canvas();
label = new Label();
push = new Button("Push");

public static void main(String []args){
LooseBall lb = new LooseBall();
public void actionPerformed(ActionEvent ae){
if(ae.getSource() == push){
makeBalloons mb = new makeBalloons();

Thread t = new Thread(mb);
//new class which makes the balloons
class makeBalloons implements Runnable{
int x = 100,y = 300;
int diameter = 7;

public void run(){
while(y > 0){
catch(InterruptedException e){
public void update(Graphics g){
public void paint(Graphics g){

<a href="" target="_blank" rel="nofollow">Free local coupons</a>
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
problem is what is update(g) in your class ? all though you have created a method update(Graphics) there is no grphics object associated anywhere there in your class. What you can do is just pass your class to that class or just a Graphics object maybe and then you can paint on it. Other wise just do all these operations in same class.

Val SCJP <BR>going for SCJD
I agree. Here's the link:
subject: Painting a frame
It's not a secret anymore!