Make sure you set layeredPane
and timer
to opaque
.
For example...
layeredPane.setOpaque(true);
You might want to, also, add layeredPane
to the main board...
public TestGameBoard() {
layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(new Dimension(680, 680));
layeredPane.setBackground(Color.GREEN);
layeredPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
layeredPane.setOpaque(true);
setLayout(new BorderLayout()); // Easy to use layout manager
add(layeredPane); // Now I'm visible ;)
}
And while I have your attention, you should always create/manipulate the UI from within the context of the Event Dispatching Thread...
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
}