2016-04-06 17 views
0

Fotoğrafımın belirli bir yerinde bir araç ipucu ayarlamak istiyorum. ve sonra bunu yaptıktan sonra, kullanıcı araç ipucunu tıklarsa, o zaman temel olarak bir resim açılır. İşte benim kodum. Sorum Sana JComponent.getToolTipText(MouseEvent) geçersiz gereken JComponent belirli bir konuma bir araç ipucu almak için yBir araç üzerinde belirtilen konumda (x, y) bir araç ipucu ayarlama

//******************************************************************** 
// 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); 
    } 

} 

cevap