JScrollPane: setViewportView(Component view) : JScrollPane « javax.swing « Java by API






JScrollPane: setViewportView(Component view)

  

import java.awt.BorderLayout;

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

public class MainClass {
  public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel dogLabel = new JLabel("www.java2s.com");
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(dogLabel);
//    scrollPane.getViewport().setView(dogLabel);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 200);
    frame.setVisible(true);
  }

}

           
         
    
  








Related examples in the same category

1.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
2.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
3.new JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
4.JScrollPane: getHorizontalScrollBar()
5.JScrollPane: getHorizontalScrollBarPolicy()
6.JScrollPane: getVerticalScrollBar()
7.JScrollPane: getVerticalScrollBarPolicy()
8.JScrollPane: setColumnHeaderView(Component view)
9.JScrollPane: setCorner(String key, Component corner)
10.JScrollPane: setRowHeaderView(Component com)