I've made a JPanel
with a image as background. But while loading the JPanel first time the rest of the added components but the image are not visible. After rolling the mouse over the image, the buttons become visible. How to make the JButtons
visible along with the image as background while loading the panel.
Here is the piece of my code:
contentPane = new JPanel();
contentPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
setContentPane(contentPane);
contentPane.setLayout(null);
homePanel.setBounds(10, 11, 959, 620);
homePanel.setLayout(null);
JPanel wizardPanel = new JPanel();
wizardPanel.setBounds(10, 295, 545, 336);
wizardPanel.setLayout(null);
homePanel.add(wizardPanel);
JLabel backgroundLabel;
try {
backgroundLabel = new JLabel(new ImageIcon(ImageIO.read(new File("images/nature.jpg"))));
backgroundLabel.setBounds(0, 0, 545, 336);
wizardPanel.add(backgroundLabel);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JButton btnNewButton = new JButton("New button");
btnNewButton.setBounds(309, 95, 89, 23);
wizardPanel.add(btnNewButton);
JButton btnNewButton_1 = new JButton("New button");
btnNewButton_1.setBounds(309, 150, 89, 23);
wizardPanel.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("New button");
btnNewButton_2.setBounds(309, 212, 89, 23);
wizardPanel.add(btnNewButton_2);