Hey,
don't have good explanation, and haven't worked with applets much, but added a
cont.paintComponents(g);
and got the buttons to show. Program was modified slightly
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class sampleimage extends JApplet implements ActionListener {
JButton b1;
JButton b2;
JButton b3;
Container cont;
boolean home = false;
boolean start = false;
boolean credits = false;
boolean a = false;
boolean b = false;
boolean c = false;
Image welcome;
MediaTracker mt;
public void init() {
mt = new MediaTracker(this);
// System.out.println(this.getCodeBase());
welcome = this.getImage(this.getCodeBase(), "Penguins.jpg");
b1 = new JButton("START");
b1.setActionCommand("b1");
b2 = new JButton("CREDITS");
b2.setActionCommand("b2");
b3 = new JButton("BACK");
b3.setActionCommand("b3");
cont = getContentPane();
cont.setLayout(null);
cont.add(b1);
b1.setVisible(true);
cont.add(b2);
cont.add(b3);
cont.setVisible(true);
b1.setBounds(150, 100, 75, 50);
b2.setBounds(150, 200, 75, 50);
b3.setBounds(150, 300, 75, 50);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
} // Init end
public boolean isOptimizedDrawingEnabled() {
return false;
}
public void actionPerformed(ActionEvent ae) {
String x = ae.getActionCommand();
if (x.equals("b1")) {
start = true;
credits = false;
home = false;
b1.setVisible(false);
b2.setVisible(false);
b3.setVisible(true);
}
if (x.equals("b2")) {
start = false;
credits = true;
home = false;
b1.setVisible(false);
b2.setVisible(false);
b3.setVisible(true);
}
if (x.equals("b3")) {
start = false;
credits = false;
home = true;
b1.setVisible(true);
b2.setVisible(true);
b3.setVisible(false);
}
repaint();
}
public void paint(Graphics g) {
home = true;
if (home) {
// g.drawImage(welcome, 85, 50, this);
g.drawImage(welcome, 300, 100, this);
}
if (start) {
Color car = new Color(244, 244, 244);
g.setColor(car);
g.fillRect(0, 0, 500, 500);
g.clearRect(0, 0, 500, 500);
}
if (credits) {
Color car = new Color(244, 244, 244);
g.setColor(car);
g.fillRect(0, 0, 500, 500);
g.clearRect(0, 0, 500, 500);
}
cont.paintComponents(g);
}
}
Regards, se52