import javax.swing.JFrame;Output
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class JScrollPaneTest {
//20행, 50열 텍스트 상자
JTextArea jta = new JTextArea(20, 50);
public JScrollPaneTest(){
JFrame f = new JFrame("JScrollPaneExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
JScrollPane jsp = new JScrollPane(jta);
f.add(jsp, BorderLayout.CENTER);
f.pack();
}
public static void main(String[] args) {
new JScrollPaneTest();
}
}
JScrollBar vjsp = jsp.getVerticalScrollBar();
JScrollBar hjsp = jsp.getHorizontalScrollBar();
import java.awt.Point;Output
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
public class JScrollPaneTest {
public JScrollPaneTest(){
JFrame f = new JFrame("JScrollPaneExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
f.setSize(300,300);
ImageIcon 이미지 = new ImageIcon("Fleur.jpg");
JLabel pimage = 새로운 JLabel();
pimage.setIcon(이미지);
JScrollPane jsp = new JScrollPane(pimage);
JViewport jvp = 새로운 JViewport();
jvp = jsp.getViewport();
jvp.setViewPosition(new Point(30,200));
f.add(jsp);
}
public static void main(String[] args) {
new JScrollPaneTest();
}
}
VERTICAL_SCROLLBAR_AS_NEEDED HORIZONTAL_SCROLLBAR_AS_NEEDED | 기본적으로 스크롤 막대가 나타나고 사라지는 경우입니다. |
VERTICAL_SCROLLBAR_ALWAYS HORIZONTAL_SCROLLBAR_ALWAYS | 항상 스크롤 막대를 표시합니다. |
VERTICAL_SCROLLBAR_NEVER HORIZONTAL_SCROLLBAR_NEVER | scrollbars 는 항상 숨겨집니다. |
jsp.setVerticalScrollBarPolicy(jsp. VERTICAL_SCROLLBAR_ALWAYS);
< / pre> 출력 :
Please disable your ad blocker and refresh the window to use this website.