import javax.swing.*;
import java.awt.*;class ImgPane extends JPanel {
private ImageIcon picture = new ImageIcon("your.gif"); private int picturew = picture.getIconWidth();
private int pictureh = picture.getIconHeight(); public void paintComponent(Graphics g) {
Dimension size = getSize(); for(int row=0; row < size.height; row += pictureh)
for(int col=0; col < size.width; col += picturew)
picture.paintIcon(this,g,col,row);
} public static void main(String[] args){
JFrame frame = new JFrame();
ImgPane panel = new ImgPane();
Container contentPane = frame.getContentPane();
contentPane.add(panel,"Center");
frame.setSize(300,200);
frame.show();
}}
import java.awt.*;class ImgPane extends JPanel {
private ImageIcon picture = new ImageIcon("your.gif"); private int picturew = picture.getIconWidth();
private int pictureh = picture.getIconHeight(); public void paintComponent(Graphics g) {
Dimension size = getSize(); for(int row=0; row < size.height; row += pictureh)
for(int col=0; col < size.width; col += picturew)
picture.paintIcon(this,g,col,row);
} public static void main(String[] args){
JFrame frame = new JFrame();
ImgPane panel = new ImgPane();
Container contentPane = frame.getContentPane();
contentPane.add(panel,"Center");
frame.setSize(300,200);
frame.show();
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货