I am making a Yahtzee dice roll program using JCreator. For class I was instructed to use images in the project. I want to display a png with the Yahtzee title the whole time while the applet runs. But once a button is clicked in the applet, the image disappears. Below is only part of my main class code since I do not think I need to post all of it. I figure its just an issue in my paint method. Thank you
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.awt.event.*;
public class DB extends JApplet {
private JPanel P;
private JPanel buttonpanel;
private JButton reset;
private JButton wildcat;
private JButton hold1;
private JButton hold2;
private JButton hold3;
private JButton hold4;
private JButton hold5;
private int x;
private boolean holda=true;
private boolean holdb=true;
private boolean holdc=true;
private boolean holdd=true;
private boolean holde=true;
public static int dice1y=250;
public static int dice2y=250;
public static int dice3y=250;
public static int dice4y=250;
public static int dice5y=250;
private int turn=3;
public void init() {
P=new P();
add(P,BorderLayout.CENTER);
buildbuttons();
add(buttonpanel, BorderLayout.SOUTH);
}
public void buildbuttons(){
buttonpanel = new JPanel();
buttonpanel.setSize(400,50);
wildcat= new JButton ("Roll");
reset= new JButton ("reset");
hold1= new JButton ("Hold");
hold2= new JButton ("Hold");
hold3= new JButton ("Hold");
hold4= new JButton ("Hold");
hold5= new JButton ("Hold");
buttonpanel.setLayout(new GridLayout(1,7));
buttonpanel.add(wildcat);
buttonpanel.add(reset);
buttonpanel.add(hold1);
buttonpanel.add(hold2);
buttonpanel.add(hold3);
buttonpanel.add(hold4);
buttonpanel.add(hold5);
wildcat.addActionListener(new ButtonListener());
reset.addActionListener(new ButtonListener());
hold1.addActionListener(new ButtonListener());
hold2.addActionListener(new ButtonListener());
hold3.addActionListener(new ButtonListener());
hold4.addActionListener(new ButtonListener());
hold5.addActionListener(new ButtonListener());
}
public void reset(){
turn=3;
dice1y=250;
dice2y=250;
dice3y=250;
dice4y=250;
dice5y=250;
holda=true;
holdb=true;
holdc=true;
holdd=true;
holde=true;
}
public void paint(Graphics g) {
super.paint(g);
g.drawImage(getImage(getDocumentBase(),"Yah copy.PNG"),25,25,420,100,this);
}
private class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
if(e.getSource()==reset){
reset();
}
if(e.getSource()==hold1){
holda = !holda;
if(holda==false){ .............//half way point