Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox - listeners

 
Bruce Quesenberry
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have JCombo component with a list of items. When I change to a different item, I want a JScrollPane [see scrollPane] to show the update with new text. This does happen, but only when you click inside the scrollPane. Is there a way to fire an action to cause this update. I would think the itemStateChanged method would take care of it. I can rely on users to think about clicking in the scrollPane to see the updated text.

scrollPane = alignmentText.GetTextAndScroll(alignmentBox.getSelectedIndex());

alignmentBox.addItemListener(this);

public void itemStateChanged(ItemEvent ie)
{
//dump the old scrollPane
remove(scrollPane);
//get new scrollPane showing text related to the new
//JCombo index
scrollPane = alignmentText.GetTextAndScrollalignmentBox.getSelectedIndex());
//add it
add(scrollPane);
}

//repaint does not work
//there is a replaceText method - but this is too cumbersome for
//the amount of text involved and even then I bet it will have the same functionality
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic