0
画像の特定の場所にツールチップを設定したいと思います。それをしたら、ユーザーがツールチップをクリックすると基本的に画像がポップアップします。ここに私のコードです。私の質問は、私は「目に見えないボタン」あなたはJComponent.getToolTipText(MouseEvent)
をオーバーライドする必要がJComponent
上の特定の位置にツールヒントを得るために、Y画像の指定された場所(x、y)にツールチップを設定する
//********************************************************************
// TransitMap.java Authors: Lewis/Loftus
//
// Demonstrates the use a scroll
//********************************************************************
import java.awt.*;
import javax.swing.*;
public class TransitMap
{
//-----------------------------------------------------------------
// Presents a frame containing a scroll pane used to view a large
// map of the New York transit system.
//-----------------------------------------------------------------
public static void main(String[] args)
{
JFrame frame = new JFrame("New York Transit Map");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon image = new ImageIcon("fortress.jpg");
JLabel imageLabel = new JLabel(image);
JScrollPane sp = new JScrollPane(imageLabel);
sp.setPreferredSize(new Dimension(450, 400));
frame.getContentPane().add(sp);
frame.pack();
frame.setVisible(true);
}
}