• Post Reply Bookmark Topic Watch Topic
  • New Topic

setEditable(true) function of jcombobox not working

 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,

i am running a for loop for creating and populating comboboxes...i am also using the function setEditable(true) to make the comboboxes editable..however in the gui i am not able to edit the comboboxes.

for(i=0;i<5;i++)
{
///some code
cmb1_1[i].setEditable(true) //is not working.

//some code
}

could anyone kindly help me.


 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi. i think you should put your setEditable(true) before the loop.
and then if you wish to set it uneditable after populating your combobox, set it to false after your loop.
 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
thanks for replying...but i can't use setEditable(true) before the for loop because the comboboxes are getting created in the loop...so if i try setting them before the loop it might give me NullPointerException...

THANKS.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE demonstrating the problem.

And dont' forget to use the "Code tags" when posting the code.
 
Sriraman Srinivasan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not sure why you are getting the problem but when i tried it, i was able to get the screen as required.

 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sriraman, please UseCodeTags. You can use the edit button to add them.
 
Sriraman Srinivasan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Rob : Will surely take care of the code tags from next time. Thanks..
 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sriraman Srinivasan: thanks for replying...i wrote the same code yet am unable to edit the comboboxes...moreover i removed all the comboboxes and just placed a jtextfield and the problem is that am not able to edit the textfield area also.I am unable to guess why am not able to edit any component(be it combobox or textfield).


please help...
 
Sriraman Srinivasan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@neha: May be if you could provide a snippet of your code, may be we will be able to tell whats wrong with that....
 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




thanks for the reply....hey this is the code where am facing problem..
 
Sriraman Srinivasan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@neha:



The only thing here I see is that setenabled is redundent since by default all component are enabled. Apart from this I dont see any other issues. Not sure why your combo is not editable.
 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sriraman Srinivasan:thanks....i am too confused why its not working....even when i remove all the comboboxes and just place a JTextField then also am unable to edit the textfield....if i click in the textfield to write anything then the cursor stands like
capital "I"(I).....:-( :-(
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!