gpt4 book ai didi

java - 如何在 Swing 中单击时放置图像?

转载 作者:行者123 更新时间:2023-12-02 07:52:01 25 4
gpt4 key购买 nike

我制作了一个用户 jTable。我想要做的是,在行的单击事件上显示光标附近的用户照片。 (我的意思是我想显示类似工具提示的内容)这可能吗?我该怎么做?像这样。但我的应用程序是桌面应用程序 http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html picture will be shown near the picture

最佳答案

1) 谷歌。 2) http://www.roseindia.net/java/example/java/swing/ImageToolTip.shtml

import javax.swing.*;
import javax.swing.text.html.*;
import java.awt.*;
import java.awt.event.*;

public class ImageToolTip {
public static void main(String[] args) {
JFrame frame = new JFrame("Image Tool Tip Frame");
JComponent button = new JButton("Cut");
String tooltiptext = "<html>" + "This is the " + "<img src=\"file:cut.gif\">" + " tool tip text." + "</html>";
button.setToolTipText(tooltiptext);
JPanel panel = new JPanel();
panel.add(button);
frame.add(panel, BorderLayout.CENTER);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

关于java - 如何在 Swing 中单击时放置图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10127995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com