swing - How to achieve abstract variable functionality in Java -
i trying create custom class extends
class (jframe
) forces assignment of variable upon implementation (i want each jframe
in application have "screen id"). java, however, not have abstract variables. nor able figure out how make interface extends jframe
. one's got head spinning =d
the class code similar this:
public interface customframe extends javax.swing.jframe { public abstract int screen_id; }
and implementation of customframe
this:
public class newframe implements customframe { public int screen_id = 5; newframe() { setvisible(true); // etc... } }
does problem make sense anyone?? know objective lost trying work out in brain....
create external frameid generator generate new id @ each call (just simple example implemented singleton: no synch or generic return type etc):
class frameidgenerator { private static int nextid = 0; private frameidgenerator(){} private static frameidgenerator instance = null; public final static frameidgenerator getinstance() { if(null == instance) instance = new frameidgenerator(); return instance; } public int getnextid() { return ++nextid; } }
Comments
Post a Comment