Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

ToolTip for JList(Hatami)

  Asked By: Oscar    Date: Apr 29    Category: Java    Views: 740
  

Tooltip for JList like that :
// Create a list, overriding the getToolTipText() method
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items) {
// This method is called as the cursor moves within the list.
public String getToolTipText(MouseEvent evt) {
// Get item index
int index = locationToIndex(evt.getPoint());

// Get item
Object item = getModel().getElementAt(index);

// Return the tool tip text
return "tool tip for "+item;
}
};

Share: 



Tagged: