الكود عندي كامل للـ GUI بس كيف أقدر أضيف صورة أو خلفية عليه؟؟
public class BabyShopPassword extends JFrame
{
private JPanel panel1;
private JPanel panel2;
private JPanel panel3;
private JPanel panel4;
private JPanel panel5;
private JLabel welcome;
private GridLayout grid;
private JLabel id;
private JLabel pass;
private JTextField idField;
private JPasswordField passField;
private JButton sign;
private JButton exit;
public BabyShopPassword()
{
super("BabyShop Products Company");
setLayout(new FlowLayout());
welcome=new JLabel("Welcome to BabyShop Products");
welcome.setToolTipText("Welcome");
panel1=new JPanel();
panel1.setBackground(Color.LIGHT_GRAY);
panel1.add(welcome);
panel1.setLayout(new FlowLayout());
panel2=new JPanel();
id=new JLabel("Employee ID");
idField=new JTextField(10);
id.setLayout(new FlowLayout());
panel2.add(id);
panel2.add(idField);
panel2.setLayout(new FlowLayout());
panel3=new JPanel();
pass=new JLabel("Password");
passField=new JPasswordField(10);
panel3.add(pass);
panel3.add(passField);
panel3.setLayout(new FlowLayout());
panel4=new JPanel();
sign=new JButton("Sign in");
exit=new JButton("Exit");
panel4.add(sign);
panel4.add(exit);
panel4.setLayout(new FlowLayout());
panel5=new JPanel();
panel5.add(panel1);
panel5.add(panel2);
panel5.add(panel3);
panel5.add(panel4);
panel5.setLayout(new GridLayout(4,1));
add(panel5);
ButtonHandler handler=new ButtonHandler();
sign.addActionListener(handler);
exit.addActionListener(handler);
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==sign)
{
BabyShopMenu baby=new BabyShopMenu();
baby.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
baby.setSize(300,300);
baby.setVisible(true);
}
else
if(event.getSource()==exit)
{
System.exit(0);
}
}
}
}