pictures/model0
pictures/model1
以下代码可以运行,有需要压缩包的伙伴可以加我qq1959521334
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
class P_JPanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
Image m_image;
int showpicture = 0;
@SuppressWarnings("static-access")
public P_JPanel() throws IOException {
Puzzle a = new Puzzle();
if (a.changetime == -1)
showpicture = 1;
File f = new File("./pictures/model" + showpicture +"/"+"model.jpg");
m_image = ImageIO.read(f);
}
public void paintComponent(Graphics g) {
g.drawImage(m_image, 0, 0, 360, 360, this);
}
}
public class Puzzle extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
int i, j;
static int changetime = 0;
Container c = getContentPane();
JButton b[] = new JButton[16];
ImageIcon ic[][] = new ImageIcon