Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rendering question

Status
Not open for further replies.

kohinoor2007

Programmer
Mar 21, 2007
69
DE

I have rendered a column of my table with a combobox.Some questions surfaced when I worked deep in to it.

I have rendered the cell which would look like a combobox only on editing as follows.

sheetColumn.setCellEditor(new DefaultCellEditor(comboBox));
//sheetColumn is my column name.

Have a function in my class,as below,where Iam passing the combo and want to trap the keypress events on the combo.

public void addKeyListener(final JComboBox test){


Component comp1;
comp1 = test.getEditor().getEditorComponent(); //[1]

My questions are :
[1]What does [1] return :--> a JComboBox

So for example if I have a "KeyPressed" event handler as follows:

public void keyPressed(KeyEvent e){

e.getSource();
e.getComponent();

}}

[2]What does "getSource" & "getComponent" return.Do they return the same JComboBox as [1].

Thanks
 

Yes, I tried it before posting here.
In my Program comp1 was returning ComboBox.

but "e.Getsource" was crashing.Was wondering why?.Thought that as the keypress was also coming from the combobox & it should also return JComboBox?...

Is wondering why they are returning different results...
 
What do you mean by "crash"? NullPointerException?

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top