java - Methods lacking return types and no void? -
this piece of code in textbook, i'm not understanding method testpanels(). has no return type , no void. how can happen?
public class testpanels extends jframe { public testpanels() { jpanel p1 = new jpanel(); p1.setlayout(new gridlayout(4,3)); (int = 1; <= 9; i++) { p1.add(new jbutton(""+i)); } p1.add(new jbutton(""+0)); p1.add(new jbutton("start")); p1.add(new jbutton("stop")); jpanel p2 = new jpanel(new borderlayout()); p2.add(new jtextfield("time displayed here"), borderlayout.north); p2.add(p1, borderlayout.center); add(p2, borderlayout.east); add(new jbutton("food placed here"), borderlayout.west); } public static void main(string[] args) { testpanels frame = new testpanels(); frame.settitle("the front view of microwave oven"); frame.setsize(400, 250); frame.setlocationrelativeto(null); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); } }
it constructor , not method. methods have return-type or void (no return value).
Comments
Post a Comment