Hi friend,
If you want to know about the use of JScrollPane class of java, then please refer following example:
Code:
import javax.swing.JScrollPane;
import javax.swing.border.LineBorder;
public class AddingToJScrollPaneDM {
public static void main(String args[]) {
JFrame frameK = new JFrame("Tabbed Pane Sample");
frameK.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label2 = new JLabel("Label");
label2.setPreferredSize(new Dimension(1200, 1000));
JScrollPane jScrollPane2 = new JScrollPane(label2);
JButton jButton1 = new JButton();
jScrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jScrollPane2.setViewportBorder(new LineBorder(Color.RED));
jScrollPane2.getViewport().add(jButton1, null);
frameK.add(jScrollPane, BorderLayout.CENTER);
frameK.setSize(400, 150);
frameK.setVisible(true);
}
}
Bookmarks