I am trying to display a JPanel in a JFrame. The Jrame works but I can't get the JPanel to display.
My whole class spent an hour on this today. Teacher included. Not luck. Eclipse says there are no errors Can someone please alert me to my mistake?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// make a JFrame and bits
public class MySystemGUI extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
private JFrame myFrame;
private JTextField LLName, LLAddress, LLPhone, LLbankDeets;
private JButton sub1;
private JLabel LLNameT, LLAddressT, LLPhoneT, LLbankDeetsT;
private JPanel LLJP()
{
JPanel JP1 = new JPanel();
LLNameT = new JLabel ("Enter Landlord name");
LLName = new JTextField(30);
LLAddressT = new JLabel ("Enter Landlord Address ");
LLAddress = new JTextField(40);
LLPhoneT = new JLabel ("Enter Landlod Phone No.");
LLPhone = new JTextField(10);
LLbankDeetsT = new JLabel ("Enter Landlod Bank details");
LLbankDeets = new JTextField(10);
sub1 = new JButton("Submit");
JP1.add(LLNameT);
JP1.add(LLName);
JP1.add(LLAddressT);
JP1.add(LLAddress);
JP1.add(LLPhoneT);
JP1.add(LLPhone);
JP1.add(LLbankDeetsT );
JP1.add(LLbankDeets);
JP1.add(sub1);
//myFrame.add(JP1 );
return JP1;
}
// Set up frame
public MySystemGUI()
{
myFrame = new JFrame ();
JPanel myPanel = LLJP();
myFrame.add(myPanel,"South");
this.setLayout(new GridBagLayout());
this.setSize(700, 500);
this.setTitle("My System GUI");
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBackground(Color.blue);
}
//run this bitch
public static void main (String[] args)
{
new MySystemGUI();
}
@Override
public void actionPerformed(ActionEvent e)
{
}
}