This is the code
void CreateGUI()
{
try
{
//myPicture = ImageIO.read(new File("Companylogo_FINAL.jpg"));
myPicture = ImageIO.read(new File("Companylogo_FINAL.jpg"));
//myPicture = ImageIO.read(getClass().getResource("Companylogo_FINAL.jpg"));
/*java.net.URL u = getClass().getResource("/resources/Companylogo_FINAL.jpg");
System.out.println(u);
myPicture = ImageIO.read(u);*/
/*try {*/
//myPicture = ImageIO.read(new File("Companylogo_FINAL.jpg"));
/*}
catch (IOException e)
{
}*/
ImageIcon img = new ImageIcon(myPicture);
//frame.setIconImage(img.getImage());
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
nameTextField = new JTextField(20);
birthDateTextField = new JTextField(20);
lastnameTextField = new JTextField(20);
nameLabel = new JLabel("Name:");
birthDateLabel = new JLabel("Birth Date:");
lastnameLabel = new JLabel("Last Name:");
JLabel lbl = new JLabel(new ImageIcon(myPicture));
panel.setLayout(new MigLayout("fillx,filly", "[]rel:push[]", "[]1[]"));
//ADD A TABBED PANE
panel.setBorder(BorderFactory.createTitledBorder("New Company :"));
panel.add(lbl,"wrap, dock north, align right,gapbottom 10");
buttonpanel.add(createbtn);
buttonpanel.add(editbtn);
editbtn.setVisible(true);
buttonpanel.add(firstbtn);
firstbtn.setVisible(false);
buttonpanel.add(previousbtn);
previousbtn.setVisible(false);
buttonpanel.add(nextbtn);
nextbtn.setVisible(false);
buttonpanel.add(lastbtn);
lastbtn.setVisible(false);
buttonpanel.add(updatebtn);
updatebtn.setVisible(false);
buttonpanel.add(printbtn);
printbtn.setVisible(false);
buttonpanel.add(delbtn);
delbtn.setVisible(false);
buttonpanel.add(cancelbtn);
buttonpanel.add(currenttime);
panel.add(nameLabel);
panel.add(nameTextField,"align label");
panel.add(lastnameLabel, "gap related");
panel.add(lastnameTextField, "wrap,align label");
panel.add(birthDateLabel, "gap related");
panel.add(birthDateTextField,"align label");
JPanel widget1 = new JPanel();
JPanel widget2 = new JPanel();
JPanel widget3 = new JPanel();
panel.add(widget1, "west, gapright 5, w 80");
panel.add(widget2, "east, gapright 5, w 80");
panel.add(widget3, "south, gapbottom 100, w 80");
widget3.setBorder(BorderFactory.createTitledBorder("New Border :"));
frame.add(widget3);
frame.add(tabbedPane);
frame.add(buttonpanel,BorderLayout.SOUTH);
buttonpanel.setBackground(Color.WHITE);
frame.add(panel);
frame.add(tabbedPane);
tabbedPane.add(panel);
tabbedPane.add(Employer);
tabbedPane.add(Attendance);
tabbedPane.add(Salary);
tabbedPane.addTab("Employer Details",Employer);
tabbedPane.addTab("Make Monthly Salary",Salary);
tabbedPane.addTab("Mark Attendance", Attendance);
tabbedPane.setFont( new Font( "Dialog", Font.BOLD|Font.ITALIC,12 ));
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x=(int)((dimension.getWidth() - 760)/2);
int y=(int)((dimension.getHeight() - 550)/2);
frame.setLocation(x, y);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
createbtn.requestFocusInWindow();
frame.setVisible(true);
}
I'm not able to add panel to frame.Error on that line.
frame.add(widget3);
Error I'm getting is>
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException