JTable With JComboBox Problem

Hi,

I have a JTable with 4 columns, in which each cell contains JComboBox: one editable, others non-editable. when I click on the cell, the popup menu comes down. How can I achieve this through keyboard?

Again when i put text in editable combo and press "ENTER", control goes to the next some component in the dialog, instead of the next cell of the table. How can I stop this?

[396 byte] By [mohangupta_chegua] at [2007-11-27 10:40:37]
# 1

by using the DefaultTableCellRenderer and the Editor, u can achieve this.

nirgun_xyza at 2007-7-28 19:07:50 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hi,

To open the comoboBox with keyboard you can use a class who implements a KeyAdapter.

There you overwrite the method : public void keyPressed(KeyEvent ke)

.

In this method you can set for a given key-input a action on your app.

For example :

You press 'Q' and the ComobBox -yourComboBox - shows the entrylist.

public void keyPressed(KeyEvent ke){ if(ke.getKeyCode() == ke.VK_Q){yourComboBox.showPopup();} else if(...){...}}

For the behavior of default keyboard-input on components you must override the InputMap of the table. For this read some tutorials about this. Its not difficult.

Message was edited by:

Olek

Oleka at 2007-7-28 19:07:50 > top of Java-index,Desktop,Core GUI APIs...