|
クリックして下さい。 |
| JScrollPaneSample.java |
|
import
java.awt.*; |
|
|
import
java.awt.event.*; |
|
|
import javax.swing.*; |
|
|
public class
JScrollPaneSample extends JFrame { |
|
| Container
contentPane; |
|
| JLabel lbl = new
JLabel(new ImageIcon("image.jpg")); |
|
| JScrollPane
srl = new JScrollPane(lbl); |
← @JScrollPaneを生成 |
| public JScrollPaneSample()
{ |
|
| super(JScrollPaneSample); |
|
| addWindowAdapter(new
WindowListener() { |
|
| public
void windowClosing(WindowEvent e) { |
|
| System.exit(0); |
|
| } |
|
| }); |
|
| contentPane
= getContentPane(); |
|
| contentPane.setLayout(new
BorderLayout()); |
|
| contentPane.add(BorderLayout.CENTER,
srl); |
← AsrlオブジェクトをCenter位置に配置 |
| setSize(200,100); |
|
| setVisible(true); |
|
| } |
|
| public static
void main(String[] args) { |
|
| new
JScrollPaneSample(); |
|
| } |
|
|
} |
|
| |
|
@JScrollPane
srl = new
JScrollPane(lbl);
ラベルlblをJViewportに指定してJScrollPaneのオブジェクトを生成しています。 |
A ContentPane.add(BorderLayout.CENTER,srl);
CENTERの位置にJScrollPaneオブジェクトを配置しています。 |
| もどる |