📄 scrollpanedemo.java
字号:
import javax.swing.*;
public class ScrollPaneDemo extends JFrame {
JScrollPane scrollpane = new JScrollPane();
Icon icon=new ImageIcon("Image.jpg");
JLabel lbIcon = new JLabel(icon);
public ScrollPaneDemo() {
super("滚动面板示例");
setSize(350,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setLayout(){
//向滚动面板的浏览窗口添加组件,
scrollpane.getViewport().add(lbIcon);
this.getContentPane().add(scrollpane);
}
public static void main(String[] args) {
ScrollPaneDemo frame = new ScrollPaneDemo();
frame.setLayout();
frame.show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -