How can i resolve the Exception in thread "main" java.lang.NoSuchMethodError: main -
i have code. eclipse tells me syntax correct when run program gives me error:
exception in thread "main" java.lang.nosuchmethoderror: main
what's wrong?
import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; public class main extends jframe { private static final long serialversionuid = 1l; public void main(string[] args){ jframe main = new jframe("test"); main.setsize(600, 600); main.setlocationrelativeto(null); main.setvisible(true); main.setdefaultcloseoperation(jframe.exit_on_close); //adding jpanel jpanel panel = new jpanel(); main.add(panel); //jpanel settings panel.setlayout(null); panel.setbackground(color.green); //adding jbutton jbutton button = new jbutton("button 1"); jbutton button2 = new jbutton("button2"); panel.add(button); panel.add(button2); //button action button.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e) { jpanel panel = new jpanel(); jpanel panel2 = new jpanel(); main.this.getcontentpane().remove(panel); main.this.getcontentpane().add(panel2); main.this.getcontentpane().validate(); } }); //jbutton settings button.setbounds(70, 160, 200, 200); button2.setbounds(320, 160, 200, 200); } }
your main method not static
, , should make static
. check this see why
public static void main(string [] args)
Comments
Post a Comment