在Jlist项目中添加ToolTipText [英] Add ToolTipText in Jlist Item(s)

查看:57
本文介绍了在Jlist项目中添加ToolTipText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static void populateJList(JList list) {
        ArrayList<String> contents= DataAccess.getContents();
        DefaultListModel listModel = new DefaultListModel();
        for (String string : contents) {
            listModel.addElement(string);
        }
        preset.setModel(listModel);
}

我有填充我的JList的方法,有没有办法我可以在JList中添加每个项目的toolTipText?

I have this method that populates my JList, is there a way that I can add toolTipText of every item in the JList?

推荐答案

  1. 您可以重写JList的getToolTipText(..)方法.

  1. You can override the getToolTipText(..) method of the JList.

我相信您也可以使用调用setToolTipText(...)方法的自定义渲染器.

I believe you can also use a custom renderer which invokes the setToolTipText(...) method.

这篇关于在Jlist项目中添加ToolTipText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆