java - JTextField with JComboBox is not working properly -
i want jtextfield
appear when user select "extra" in jcombobox
list , hidden otherwise. jtextfield not appearing when user selecting "extra" appearing if shrink window , enlarge again. after doing working properly, first time not appearing. why behaving that? solution this?
here code:
getcmbjtocsv_c_8().addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { { input3 = (string)adaptor.getcmbjtocsv_c_8().getselecteditem(); adaptor.gettxtjtocsv_c_8().setvisible(false); if(input3.equals("extra")){ adaptor.gettxtjtocsv_c_8().setvisible(true); } }
i have changed string comparison , i'm still getting same result.
by default swing components have size of (0, 0). size/location of component determined layout manager when frame packed or made visible.
so guess since start text field invisible size of parent panel not include text field. when resize frame text field appears because size , size of panel recalculated.
now size of text field has been calculated can toggle visibility required.
if doesn't post sscce demonstrates problem. create frame combo box , text field demonstrate problem. in future questions should contain sscce since can't guess context of application based on few lines of code.
Comments
Post a Comment