File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JComboBox - listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox - listeners" Watch "JComboBox - listeners" New topic
Author

JComboBox - listeners

Bruce Quesenberry
Greenhorn

Joined: Apr 02, 2001
Posts: 7
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.
 
subject: JComboBox - listeners