2016-04-06 36 views
0

我想在我的照片的特定位置設置工具提示。然後一旦我這樣做,我想如果用戶點擊工具提示,然後基本上彈出一個圖片。這是我的代碼。我的問題是我如何做一個「隱形按鈕」基本上是無形的盒子,從點X到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); 
    } 

} 

回答

相關問題