JScrollPane: display a large component within a smaller display area
Adding the component to a JViewport
Identifying the component to be scrolled can be done in one of two ways.
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
public class JScrollPaneViewport
{
public static void main(String args[])
{
JFrame frame = new JFrame("Tabbed Pane Sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Label");
label.setPreferredSize(new Dimension(1000,1000));
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.setViewportView(label);
frame.add(jScrollPane, BorderLayout.CENTER);
frame.setSize(400, 150);
frame.setVisible(true);
}
}
Wednesday, October 1, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment