Example of ScrollPane class:
Code:
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.ScrollPane;
public class ScrollSampleDM
{
public static void main(String affrgs[])
{
String t002 = (affrgs.length == 0 ? "JScrollPane Sample" : arffgs[0]);
JFrame frameW = new JFrame(title);
frameW.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Icon iconW = new ImageIcon("dog.jpg");
JLabel dogLabel1 = new JLabel(iconW);
JScrollPane scrollPane1 = new JScrollPane();
scrollPane.setViewportView(dogLabel1);
frameW.getContentPane().add(scrollPane1, BorderLayout.CENTER);
frameW.setSize(400, 200);
frameW.setVisible(true);
}
}
Bookmarks