I am trying to do a slideshow in a JApplet and I keep getting an error on the "public void paint (Graphics g)'s." I know its outdated but its for a class in high school. This is my first time doing this so please im sorry if its a stupid question. The project is just to have an image with a yellow box around text and image.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class timers extends JApplet implements ActionListener
{
Timer timer1;
int seconds = 1;
Image picture1;
Image picture2;
Image picture3;
Image picture4;
Image picture5;
public void init ()
{
// set applet size
setSize (800, 600);
//constructor Timer(int millidelay, ActionListener l)
timer1 = new Timer (1000, this);
picture1 = getImage (getDocumentBase (), "Red_Color.jpeg");
picture2 = getImage (getDocumentBase (), "Color-blue.jpeg");
picture3 = getImage (getDocumentBase (), "Color-yellow.jpeg");
picture4 = getImage (getDocumentBase (), "green.png");
picture5 = getImage (getDocumentBase (), "pink.jpeg");
//
repaint ();
}
public void start ()
{
timer1.start ();
}
public void stop ()
{
timer1.stop ();
}
public void destroy ()
{
//System.exit(0);
}
public void paint (Graphics g)
{
g.setColor (Color.BLACK);
g.fillRect (0, 0, 800, 600);
g.setFont (new Font ("Helvetica", Font.PLAIN, 20));
g.setColor (Color.yellow);
g.drawString ("This is the colour red", 270, 473);
g.drawImage (picture1, 300, 200, 200, 200, this);
g.setColor (Color.yellow);
g.drawRect (275, 175, 251, 251);
g.drawRect (269, 445, 265, 40);
} // end of paint
public void paint (Graphics g)
{
g.setColor (Color.BLACK);
g.fillRect (0, 0, 800, 600);
g.setFont (new Font ("Helvetica", Font.PLAIN, 20));
g.setColor (Color.yellow);
g.drawString ("This is the colour blue", 270, 473);
g.drawImage (picture2, 300, 200, 200, 200, this);
g.setColor (Color.yellow);
g.drawRect (275, 175, 251, 251);
g.drawRect (269, 445, 265, 40);
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource () == timer1)
// timer is firing
// increment second counter
seconds++;
//call paint method
repaint ();
}
}