62,614
社区成员
发帖
与我相关
我的任务
分享
class Animater extends JPanel {
Animater() {
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
ImageIcon img = new ImageIcon("map2.jpg");
this.setSize(img.getIconWidth(), img.getIconHeight());
System.out.println(img.getIconHeight());
img.paintIcon(this, g, 0, 0);
}
}
public class mainframe extends JFrame {
public mainframe() {
super("地图");
getContentPane().setLayout(null);
Animater am= new Animater();
Container c= this.getContentPane();
JScrollPane scrollPane = new JScrollPane(am);
scrollPane.setAutoscrolls(true);
scrollPane.setBounds(0, 0, 1016, 596);
scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
c.add(scrollPane);
this.setSize(1024,734);
this.setVisible(true);
}
}
public class main {
public static void main(String[] args) {
mainframe mf= new mainframe();
}
}