Question: *FROM JAVA SOFTWARE SOLTUIONS 8TH EDITION* In this programming challenge you will demonstrate the use of a Scroll Pane. First study Listing 11.13 on p.

*FROM JAVA SOFTWARE SOLTUIONS 8TH EDITION*

In this programming challenge you will demonstrate the use of a Scroll Pane.

First study Listing 11.13 on p. 570 of your text.. This program displays a New York Subway Transit Map in a scroll pane. You will modify it in two ways:

1. First you will substitute a satellite image of an area in Kabul, Afganistan in your scroll pane. Notice that the satellite map has an untitled placemark in the center.

2. You want to display a tool tip when you mouse over this placemark. The short line of text that is displayed should read: "Bala Hissar fortress."

3. When the user actually clicks on the placemark an image of the Bala Hissar fortress should pop up on the screen. The images you need are all in the attached folder, including the image of the Bala Hissar fortress.

Code :

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("newyork.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); } 

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!