// 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;
        }
    };

 

Related Examples

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
相关资源
相似解决方案