• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox setEditor()

 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to set the editor in a non-editable JComboBox.
<code>
JComboBox box = new JComboBox();
box.setEditor(BasicComboBoxEditor {
/**
* @param item
*/
public void setItem(Object item) {
System.out.println("set item");
super.setItem(item);
editor.selectAll();
}
});
</code>
When I use the above code the editor is not used. Any thoughts?
Thank you.
Yoo-Jin.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't have to set the Editor explicitly, just use
comboBox.setEditable(true);
setting the Editor makes only sense if you want to use an Editor _other_ than a JTextField which is the default. even then you have to always make the combo box editable in the first place.
cheers
 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chantal,
Actually, the reason I want to set the editor is because of Bug Id 4648654:REGRESSION: Editable JComboBox focus misbehaves under Windows look and feel. I should have stated this in my first message. This seems to also apply to a non-editable JComboBox with a JActiveX component in the same container.
Basically, the JComboBox freezes the whole application if you click on it in a certain order.
The workaround was to set the editor with the code in my first message.
This bug is fixed in builds greater than 1.4.0-b92. However, they latest is in rfc so we cannot include it in our product.

Yoo-Jin.
[ August 22, 2002: Message edited by: Yoo-Jin Lee ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!