📄 scrolldemo.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ScrollDemo {
static JFrame jframe = new JFrame("Example");
public static void setupFrame() {
jframe.setSize(200,200);
jframe.getContentPane().setLayout( new FlowLayout() );
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
jframe.addWindowListener(l);
}
public static void main(String[] args) {
setupFrame();
MyJPanel mjp = new MyJPanel();
JScrollPane jsp = new JScrollPane( mjp );
jsp.setPreferredSize( new Dimension(150, 150));
jframe.getContentPane().add(jsp);
jframe.setVisible(true);
mjp.requestFocus();
}
}
class MyJPanel extends JPanel {
JLabel jl = new JLabel(new ImageIcon( "bmw.jpg"));
{ add(jl); // instance initializer
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -