ScrollPane
java.awt.ScrollPane클래스
- 오직 한개의 객체만 배치한다.
- 여러 개의 객체를 포함시키려면 패널을 ScrollPane에 붙이고 패널위에 다른 객체를 붙인다.
- 수직 수평 옵션이 존재한다.
- 생성자에게 전달할수 있는 값 :
ScrollPane.SCROLLBARS_AS_NEEDED(기본값)
- 패널의 크기가 ScrollPane의 크기를 초솨할 때만 스크롤 바를 얻는다.
ScrollPane.SCROLLBARS_AS_ALWAYS
ScrollPane.SCROLLBARS_AS_NEVER
*
import java.awt.*;
import java.awt.event.*;
public class TestScrollPane extends Frame{
ScrollPane sp;
TextField tf1;
TextField tf2;
TextField tf3;
TextField tf4;
TextField tf5;
TextField tf6;
TextField tf7;
TextField tf8;
public TestScrollPane() {
tf1 = new TextField("Text Field Number 1");
tf2 = new TextField("Text Field Number 2");
tf3 = new TextField("Text Field Number 3");
tf4 = new TextField("Text Field Number 4");
tf5 = new TextField("Text Field Number 5");
tf6 = new TextField("Text Field Number 6");
tf7 = new TextField("Text Field Number 7");
tf8 = new TextField("Text Field Number 8");
Panel p1 = new Panel();
p1.add(tf1);
p1.add(tf2);
p1.add(tf3);
p1.add(tf4);
p1.add(tf5);
p1.add(tf6);
p1.add(tf7);
p1.add(tf8);
sp = new ScrollPane(); //ScrollPane의 인스턴스화
sp.add(p1); //패널 추가
add(sp); //객체가 아닌 프레임에 ScrollPane 추가
addWindowListener(new WinCloser());
setTitle("Using a ScrollPane");
setBounds(100,100,300,300);
setVisible(true);
}
public static void main(String[] args) {
TestScrollPane tsp = new TestScrollPane();
}
}class WinCloser extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}*