How to add a tooltip to a cell in a jtable?

前端 未结 3 2121
自闭症患者
自闭症患者 2020-12-29 23:00

I have a table where each row represents a picture. In the column Path I store its absolute path. The string being kinda long, I would like that when I hover the mouse over

3条回答
  •  盖世英雄少女心
    2020-12-29 23:12

    You say you store an absolute path in a cell. You are probably using a JLabel for setting absolute path string. Suppose you have a label in your cell, use html tags for expressing tooltip content:

    JLabel label = new JLabel("Bla bla");
    label.setToolTipText("

    information about cell

    ");

    setToolTipText() can be used for some other Swing components if you are using something other than JLabel.

提交回复
热议问题