this small java program im working on fun.
issue is, components in searchtab class not show! in initframe(), have jtabbedplane, shows when comment out lot of components in searchtab class, not show when un-comment few components the searchtab class.
what doing wrong? dont know other simplier way ask this, sorry if unclear on question.
import java.awt.*; import javax.swing.*; public class view{ public static jframe mainframe; public static jtabbedpane tabs; public static void initframe(){ mainframe = new jframe("address book proggie"); mainframe.setsize(600,300); mainframe.setdefaultcloseoperation(jframe.exit_on_close); mainframe.setvisible(true); tabs = new jtabbedpane(); tabs.addtab("search", new searchtab()); tabs.addtab("insert", new inserttab("this insert tab!")); tabs.addtab("delete", new deletetab("this tab used delete items database")); mainframe.add(tabs); } // public static void main(string args[]){ // initframe(); // } } class deletetab extends jpanel{ public deletetab(string str){ jlabel deletelabel = new jlabel(str); add(deletelabel); } } class inserttab extends jpanel{ public inserttab(string str){ jlabel insertlabel = new jlabel(str); add(insertlabel); } } class searchtab extends jpanel{ public searchtab(){ //give panel border) this.setborder(borderfactory.creatematteborder(10,10,10,10, color.blue)); //set group layout grouplayout gl = new grouplayout(this); this.setlayout(gl); gl.setautocreategaps(true); //create labels.. jlabel searchlabel = new jlabel("search by..."); jlabel namelabel = new jlabel("name: "); jlabel addresslabel = new jlabel("address: "); jlabel phonelabel = new jlabel("phone number: "); //create text fields... jtextfield namefield = new jtextfield(20); jtextfield addressfield = new jtextfield(20); jtextfield phonefield = new jtextfield(20); gl.sethorizontalgroup(gl.createsequentialgroup() .addgroup(gl.createparallelgroup(grouplayout.alignment.leading) .addcomponent(searchlabel)) .addgroup(gl.createparallelgroup(grouplayout.alignment.leading) .addcomponent(namelabel) .addcomponent(addresslabel) .addcomponent(phonelabel)) ); gl.setverticalgroup(gl.createsequentialgroup() .addgroup(gl.createparallelgroup(grouplayout.alignment.baseline) .addcomponent(searchlabel)) .addgroup(gl.createparallelgroup(grouplayout.alignment.baseline) .addcomponent(namelabel) .addcomponent(namefield)) .addgroup(gl.createparallelgroup(grouplayout.alignment.baseline) .addcomponent(addresslabel) .addcomponent(addressfield)) .addgroup(gl.createparallelgroup(grouplayout.alignment.baseline) .addcomponent(phonelabel) .addcomponent(phonefield)) ); system.out.println("hello there"); } }
Comments
Post a Comment