For the life of me, I can't figure out what's wrong.
I want my Applet to have two Panels. One in BorderLayout.Center, and another in South.
Right now, all I'm trying to do is get one of the two panels to appear. It has a paint method which should draw a border, but nothing happens. In fact, the main content pane doesn't even show it's background color!
Perhaps there's something wrong with the DisplayPanel class I define at the end? It's just supposed to be a JPanel, basically, but I needed to be able to paint on it. So, I defined a the DisplayPanel class.
import java.awt.*; import javax.swing.*; public class ShooterApplet extends JApplet { private int height, width; Container mainContentPane; DisplayPanel displayPanel; JPanel controlPanel; public void init() { mainContentPane = getContentPane(); mainContentPane.setSize(new Dimension(500,500)); mainContentPane.setLayout(new BorderLayout()); mainContentPane.setBackground(Color.GRAY); displayPanel = new DisplayPanel(); mainContentPane.add(displayPanel, BorderLayout.CENTER); validate(); } public void start() { } public void paint(Graphics g) { } } class DisplayPanel extends JPanel { private int height, width; public DisplayPanel() { super(); height = getHeight(); width = getWidth(); } public void paint(Graphics g) { g.drawRect(0,0,width-1,height-1); } }