java - Short way of writing JFrame settings -


i'm creating gui , have code:

frame.add(container); frame.pack(); frame.setlocation(200, 200); frame.setvisible(true); 

is there shorter way write this? i'm asking out of curiosity i'm trying learn new things.

i think i've come across this, can't work in application.

frame.add(container).setlocation(200,200).pack().setvisible(); 

you override jframe this. dont se benefit want do.

public myframe extends jframe{     public jframe add(container container){     super.add(container);     return this;   }    public jframe setlocation(int x, int y){     super.setlocation(x,y);     return this;   }   //and on } 

and use this.

myframe frame = new myframe(); frame.add(somecontainer).setlocation(200,200)..... 

Comments