Hi guys
i have extended a class to JPanel to create a image panel witch is loading a image as a background code is follows
and then i use this panel to my JFrameCode:
public class ImagePanel extends JPanel {
private Image img;
public ImagePanel (Image img){
this.img = img;
Dimension size = new Dimension(img.getWidth(null),img.getHeight(null));
setSize(size);
setPreferredSize(size);
setMaximumSize(size);
setMinimumSize(size);
setLayout(null);
}
public void paintComponent(Graphics g){
g.drawImage(img,0,0,null);
}
i wanted to add a JLabel and JButton to this panel. i have added both of them. there is no error in the code but when i run the program it doesn't show the Jbutton and JLabel
Code..
if any one know the solution please postCode:private static final long serialVersionUID = 1L;
static ImagePanel panel = new ImagePanel(new ImageIcon("res/back10.png").getImage());
static JLabel username = new JLabel("User Name");
static JButton ok = new JButton("ok");
public JWinTest(){
super("Enter Username | Password");
getContentPane().add(panel);
panel.add(username);
panel.add(ok);
setVisible(true);
}
public static void main(String[] args){
JWinTest t = new JWinTest();
t.getContentPane().add(panel);
t.pack();
t.setVisible(true);
}
it would be great full
thank you guys for your time

