public static void main(String[] args) {
myForm.setSize(500, 400);
myForm.setLocation(0, 0);
myForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myForm.setVisible(true);
// try {
// myForm.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("C:\\Users\\Heshamm\\Desktop\\light.jpg"))) ) );
//} catch (IOException e1) {
//JOptionPane.showMessageDialog(null, "Error !!!", null, JOptionPane.PLAIN_MESSAGE);
//}
draw.mai(myForm, jp1, button, tf[0], tf[1], tf[2], tf[3]);
And this is the mai() function in another class
public void mai(JFrame myForm, JPanel jp1, JButton[] button, JTextField tf1, JTextField tf2, JTextField tf3, JTextField tf4)
{
myForm.getContentPane().removeAll();
jp1.removeAll();
jp1.add(button[0]);
jp1.add(button[1]);
jp1.add(button[2]);
jp1.add(button[3]);
jp1.add(button[9]);
jp1.add(button[4]);
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
Hotel.update();
}
Okay so, I have this code, and I wanted the img to be displayed as a background behind the buttons, but when I uncomment try and whats inside it, the frame only displays the background without the buttons, how can I fix it?
And here's the update() function.
public static void update()
{
cbChoice="";
myForm.add(jp1);
myForm.repaint();
myForm.revalidate();
}
Thanks in advance.