I want to show a window that contains information when a user hovers over an item in a list. Something like the following:
How can i do this? This can be seen in a chat application such as pidgin or spark.
Perhaps you are after such a hint as functionality. If so, look at a ListCellRenderer component such as JLabel and set the tip of the JLabel tool.
eg. Using HTML rendering in the tooltip.
import javax.swing.*; class LabelWithHtmlTooltip { public static void main(String[] args) { Runnable r = new Runnable() { public void run() { String html = "<html><body>" + "<h1>Header</h1>" + "<img src='http://pscode.org/media/starzoom-thumb.gif' " + "width='160' height='120'>"; JLabel label = new JLabel("Point at me!"); label.setToolTipText(html); JOptionPane.showMessageDialog(null, label); } }; SwingUtilities.invokeLater(r); } }
Here's how I would try to implement it:
MouseListener MouseMotionListener JList. , , (). , . JList, . .
( , , , ), SwingUtilities.invokeLater, . JList locationToIndex, , .
Source: https://habr.com/ru/post/1795479/More articles:How can I use the latest version of HttpComponents on Android? - javaEnter dates from Python groupby group - pythonWhy does my application crash when I add an insert row in my table view? - iosWhy does the application crash when I add a row to the table view? - iphoneRadioButton or CheckBox in AlertDialog - androidiPhone SDK: How to check if the IP address is actually entered by the user? - objective-cКак я могу нарисовать точку или линию на карте в j2me? - google-maps-api-3Adding and removing items dynamically in the same view with Entity Framework and MVC - asp.netIPhone files are not resistant - c #How do I iterate over multiple files while maintaining the base name for further processing? - bashAll Articles