-
Notifications
You must be signed in to change notification settings - Fork 3
/
JScrP.java
33 lines (29 loc) · 873 Bytes
/
JScrP.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Demonstration of JScrollPane
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/* <applet code = "JScrP" width = 100 height = 100> </applet> */
public class JScrP extends JApplet
{
public void init()
{
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel jp = new JPanel();
jp.setLayout(new GridLayout(20,20));
int b = 1;
for(int i = 0; i <=20; i++)
{
for(int j = 0; j <=20; j++)
{
jp.add(new JButton("Button" +b));
++b;
}
}
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jp,v,h);
cp.add(jsp,BorderLayout.CENTER);
}
}