如何将图像的位置从网格框移动到网格框

时间:2015-05-05 22:33:12

标签: java grid-layout

我需要知道如何使用GridLayout将我的棋子从正方形移动到正方形。我创建了GridLayout,我将在下面发布它的代码。我还没有真正制作棋子,但我只需要知道如何通过点击一个方框将图像从一个盒子移动到另一个盒子。如果需要,我的类称为GridLayout。

GridLayout代码:

public Frame(){

    //I cut out the beginning part that included adding the buttons to the top of the Frame, but this was the constructor.

public static void main(String args[]){
    ImageIcon icon1 = new ImageIcon("checkerboard.jpg"); 
    JLabel bg = new JLabel();
    bg.setIcon(icon1);

    frame.pack();
    frame.setTitle("Checkers");
    frame.setSize(414, 474);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setBackground(Color.WHITE);
    frame.add(bg);
    frame.setLocale(null);
    frame.setResizable(false);
}

//I also cut out a changeSize() method that was activated when the start button was pressed.

}

段:

scanf

0 个答案:

没有答案