0

I got a problem when I build a class to use its own module like VB.net, because I don't want to initialize the Button's Label and TextField a lot of line in everyday, but I got an error when button didn't initialize it.


When I try to build the program below, I get the following error:

Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Unknown Source) at java.awt.Container.add(Unknown Source) at EmployeeGUI.AddLayout(EmployeeGUI.java:57) at EmployeeGUI.(EmployeeGUI.java:28) at EmployeeGUI.main(EmployeeGUI.java:89)

Here is class code:

import java.awt.Button;
    public class Init{
        public static void initButton(String btntxt,Object...btn){
            String[] btnT = btntxt.split("\\\,");
            for (int i = 0; i < btn.length; i++) {
                btn[i] = new Button(btnT[i]);
            }
        }
   }
MKII
  • 892
  • 11
  • 36
Seakleng Say
  • 350
  • 4
  • 13

0 Answers0