Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JCombobox in JTable - requestFocus not working.  RSS feed

 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have Jcombobox in JTable. In the dropdown, on choosing "Enter Value" option, combobox is editable.

Able to enter the value on Choosing 'Enter Value' but the cursor stays after Enter Value| like this.

So, I need to press backspace and deleting that Enter Value and then only able to type the value in that.

I want to highlight 'Enter Value' So that on any key press, Enter Value will get deleted.

Below is the code. Please check it and tell me where i am going wrong. I tried with FocusListener also.. But no use.

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to wrap it like this:

 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:You need to wrap it like this:



Where to put this code in the code i sent ?? Need more explanation please...
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of the current editor.requestFocus(). You must replace component with editor in Maneesh' code, and make your editor variable final for this to work.
 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried as you said, but syntax errors at the mentioned lines

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SwingUtilities#invokeLater takes one parameter, a Runnable.

If that's beyond your level of understanding, I strongly suggest you take a break from whatever you're doing and spend some time going through the basic tutorials.
 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I modified the code. Its working perfectly using SwingUtilities.invokeLater as suggested by you.


Thanks you All !!!

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!