Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox - listeners
 
Similar Threads
JCombo Box gives IllegalStateException while selection
jcombo box and jtable
Jcombo box
JCombo+JList problem
JCombo model?