JScrollPane Corner : ScrollBar « Swing JFC « Java






JScrollPane Corner

JScrollPane Corner
  
import java.awt.BorderLayout;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;

public class CornerSample {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Cornering Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Icon miniLogo = new ImageIcon("logo.gif");
    Icon acrossLogo = new ImageIcon("logo-across.jpg");
    Icon downLogo = new ImageIcon("logo-down.jpg");
    Icon bookCover = new ImageIcon("puzzlebook.jpg");
    JLabel logoLabel = new JLabel(miniLogo);
    JLabel columnLabel = new JLabel(acrossLogo);
    JLabel rowLabel = new JLabel(downLogo);
    JLabel coverLabel = new JLabel(bookCover);
    JScrollPane scrollPane = new JScrollPane(coverLabel);
    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, logoLabel);
    scrollPane.setColumnHeaderView(columnLabel);
    scrollPane.setRowHeaderView(rowLabel);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}

           
         
    
  








Related examples in the same category

1.Accessible Scroll Demo Accessible Scroll Demo
2.A quick demonstration of JScrollBar both vertical and horizontalA quick demonstration of JScrollBar both vertical and horizontal
3.JScrollPane: Button Corner SampleJScrollPane: Button Corner Sample
4.Expandable SplitPaneExpandable SplitPane
5.ScrollBar PiecesScrollBar Pieces
6.Listening for Scrollbar Value Changes in a JScrollPane Container
7.Get the default scrollbar policy
8.Make the scrollbars always appear
9.Make the scrollbars never appear
10.JScrollBar and Adjustment event
11.JScrollPane to hold scrollable component
12.Use Adjustment Events in Swing
13.Always display scrollbar
14.How to use scrollbar and react to its actionHow to use scrollbar and react to its action