Turn Applet Jframe Import Javaawt Import Javaawtevent Import Javaxswingjbutton Import Java Q27589736

Turn this applet into a JFrame:

import java.awt.*;

import java.awt.event.*;

import javax.swing.JButton;

import java.applet.*;

public class BlackBoard extends Applet implementsMouseMotionListener {

public void init() {

addMouseMotionListener(this);

setBackground(Color.black);

repaint();

JButton button=new JButton(“Erase Board”);

button.addActionListener(new ActionListener(){  

public void actionPerformed(ActionEvent e){  

repaint();

}  

});

add(button);

}

public void mouseDragged(MouseEvent me) {

Graphics g = getGraphics();

g.setColor(Color.white);

g.fillOval(me.getX(), me.getY(), 5, 5);

}

public void mouseMoved(MouseEvent me) {

}

}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.