Java painting graphics in JApplet issues
<p>I hope this does not appear too much of a newbie question. I've not done graphical style programming before. My objective is to create a pinball advergame in an applet. However, I'm falling at one of the first hurdles. My applet is not displaying the results of the paintComponent method from my Table class (which extends the JPanel). I've tried several things, such as how I load the image (currently using double buffering but I did use a mediatracker before), seeing if not having any other GUI stuff would allow the painting to occur (since I wondered if it was being drawn underneath somehow) and other things. This problem has stumped me and I'm starting to wonder (and hope) if it's something small that I've overlooked, if it is, then I'm sorry but would still be grateful for help, as I can't go very far without this problem being fixed first. My code for my Pinball (applet) and Table class are below, the other classes aren't implemented yet. Once again, I appreciate any help. </p>

<pre><code>import javax.swing.*; // useful for the drawing side, also going to be a JApplet
import java.awt.*;
import java.net.*;

public class Pinball extends JApplet {
    // variables go here
    Table table;

    // further initialisation of the GUI
    public void init() {
                        setSize(300, 300);
                table = new Table(this);
                add(table);
                                setContentPane(table); // makes our graphical JPanel container the content pane for the Applet
                // createGUI(); // this has been moved onto the table class
            }

    public void stop() {

    }

}
</code></pre>

<p>And now the Table class:</p>

<pre><code>import java.awt.*; // needed for old style graphics stuff
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.*; // gives us swing stuff
import java.io.IOException;
import java.net.*; // useful for anything using URLs

public class Table extends JPanel {
// attributes go here
    Pinball pb;
    Color bgColour;
    JPanel eastPanel;
    JPanel logoPanel;
    JPanel livesPanel;
    JPanel scorePanel;
    JPanel tablePanel;
    JPanel scrollTextPanel;
        Image logo;

    // constructor goes here
public Table(Pinball pb) {
setPreferredSize(new Dimension(300, 300));
    this.pb = pb;
    // this is not needed anymore, with the new loadImage class down the bottom
//  Toolkit tk = Toolkit.getDefaultToolkit(); // needed to get images
//  logo = tk.getImage(base + "images/logo.jpg");
        logo = loadImage("logo.jpg");
     createGUI();
        }

        // public methods go here
        // all GUI creation stuff goes here
        public void createGUI() {
            /* allows the three parts (top, middle and right) 
             * to be made through (north, center and right) */
                    setLayout(new BorderLayout());
                    // setting the background colour
                    bgColour = new Color(190, 186, 221); // makes the sky blue colour for the background.
                    setBackground(bgColour);
                                                        // now putting a panel for the east side
                    eastPanel = new JPanel();
                    eastPanel.setBackground(bgColour);
                    eastPanel.setLayout(new BorderLayout(8, 8));
                    eastPanel.setPreferredSize(new Dimension(100, 280));
                                    logoPanel = new JPanel();
    logoPanel.setBackground(Color.WHITE);
    logoPanel.setPreferredSize(new Dimension(100, 100));
    logoPanel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.white));
    //JLabel label1 = new JLabel("Logos go here");
    //logoPanel.add(label1);
    eastPanel.add(logoPanel, "North");
    livesPanel = new JPanel();
    livesPanel.setBackground(Color.WHITE);
    livesPanel.setPreferredSize(new Dimension(100, 100));
    JLabel label2 = new JLabel("Lives go here");
    livesPanel.add(label2);
    eastPanel.add(livesPanel, "Center");
    scorePanel = new JPanel();
    scorePanel.setBackground(Color.WHITE);
    scorePanel.setPreferredSize(new Dimension(100, 80));
    JLabel label3 = new JLabel("Scores go here");
    scorePanel.add(label3);
    eastPanel.add(scorePanel, "South");
add(eastPanel, "East");
    tablePanel = new JPanel();
    tablePanel.setBackground(bgColour);
    tablePanel.setPreferredSize(new Dimension(200, 280));
    add(tablePanel, "Center");
    scrollTextPanel = new JPanel();
    scrollTextPanel.setPreferredSize(new Dimension(300, 20));
    scrollTextPanel.setBackground(Color.WHITE);
    scrollTextPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    add(scrollTextPanel, "North");
    // repaint();
                        }

        public void paintComponent(Graphics g) {
            super.paintComponent(g);
        g.drawImage(logo, 5, 5, 90, 90, null);
        g.drawLine(0, 0, 300, 300); // for testing, does not work
              }

        // a little useful method for handling loading of images and stuff
        public BufferedImage loadImage(String filename) {
        BufferedImage image = null;
        try {
               URL url = new URL(pb.getCodeBase(), "images/" + filename);
               image = ImageIO.read(url);
            } catch (IOException e) {
            }
    return image;
        }

}
</code></pre>
