When I put the mainframe layout equal to null and run the app, it show nothing, but if I put it equal to flowlayout () it shows the labels. I don't want to use flowlayout as I want to set bounds and specify the coordinates of each components. What is the problem in the following code?
public class pr8 extends JFrame
{
Font font;
Map attributes;
JPanel MainFrame;
JPanel PicFrame;
JLabel MainTitle;
JLabel Name;
JTextField NameInput;
public pr8 (String Title)
{
super (Title);
MainFrame = new JPanel ();
this.add (MainFrame);
MainFrame.setVisible (true);
MainFrame.setLayout (null);
MainTitle = new JLabel("Student Entry Form");
MainFrame.add (MainTitle);
MainTitle.setFont(new Font("Serif", Font.PLAIN, 24));
font = MainTitle.getFont();
attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
MainTitle.setFont(font.deriveFont(attributes));
MainTitle.setBounds(400, 50, 200, 30);
Name = new JLabel ("Enter your name");
MainFrame.add (Name);
Name.setFont(new Font("Serif", Font.PLAIN, 24));
Name.setBounds (100, MainTitle.getY () + 50, 30, 30 );
NameInput = new JTextField ("Name");
MainFrame.add (NameInput);
NameInput.setBounds(Name.getX() + 30, Name.getY(), 60, 30);
}
}