home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
ScrollPanePanel.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
92 lines
/*
* @(#)ScrollPanePanel.java 1.5 98/02/02
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
import com.sun.java.swing.*;
import com.sun.java.accessibility.*;
import java.awt.*;
import java.awt.event.*;
/*
* @version 1.5 02/02/98
* @author Jeff Dinkins
* @author Peter Korn (accessibility support)
*/
public class ScrollPanePanel extends JPanel {
public ScrollPanePanel() {
setLayout(new BorderLayout());
add(new TigerScrollPane(), BorderLayout.CENTER);
}
}
class TigerScrollPane extends JScrollPane {
private JLabel makeLabel(String name, String description) {
String filename = "images/" + name;
ImageIcon image = SwingSet.sharedInstance().loadImageIcon(filename, description);
return new JLabel(image);
}
public TigerScrollPane() {
super();
JLabel horizontalRule = makeLabel("scrollpane/header.gif", "Horizontal ruler carved out of stone");
horizontalRule.getAccessibleContext().setAccessibleName("Horizontal rule");
JLabel verticalRule = makeLabel("scrollpane/column.gif", "Vertical ruler carved out of stone");
verticalRule.getAccessibleContext().setAccessibleName("Vertical rule");
JLabel tiger = makeLabel("BigTiger.gif","A rather fierce looking tiger");
tiger.getAccessibleContext().setAccessibleName("scrolled image");
tiger.getAccessibleContext().setAccessibleDescription("A rather fierce looking tiger");
JLabel cornerLL = makeLabel("scrollpane/corner.gif","Square chunk of stone (lower left)");
cornerLL.getAccessibleContext().setAccessibleName("Lower left corner");
cornerLL.getAccessibleContext().setAccessibleDescription("Square chunk of stone");
JLabel cornerLR = makeLabel("scrollpane/corner.gif","Square chunk of stone (lower right)");
cornerLR.getAccessibleContext().setAccessibleName("Lower right corner");
cornerLR.getAccessibleContext().setAccessibleDescription("Square chunk of stone");
JLabel cornerUL = makeLabel("scrollpane/corner.gif","Square chunk of stone (upper left)");
cornerUL.getAccessibleContext().setAccessibleName("Upper left corner");
cornerUL.getAccessibleContext().setAccessibleDescription("Square chunk of stone");
JLabel cornerUR = makeLabel("scrollpane/corner.gif","Square chunk of stone (upper right)");
cornerUR.getAccessibleContext().setAccessibleName("Upper right corner");
cornerUR.getAccessibleContext().setAccessibleDescription("Square chunk of stone");
setViewportView(tiger);
setRowHeaderView(verticalRule);
setColumnHeaderView(horizontalRule);
setCorner(LOWER_LEFT_CORNER, cornerLL);
setCorner(LOWER_RIGHT_CORNER, cornerLR);
setCorner(UPPER_LEFT_CORNER, cornerUL);
setCorner(UPPER_RIGHT_CORNER, cornerUR);
}
public Dimension getMinimumSize() {
return new Dimension(25, 25);
}
public boolean isOpaque() {
return true;
}
}