moveableshapetest.java

来自「用java实现接口,实现不同图形的移动效果,主要是演示接口的用法」· Java 代码 · 共 37 行

JAVA
37
字号
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2006-11-21
 * Time: 20:43:51
 * To change this template use File | Settings | File Templates.
 */
public class MoveableShapeTest {
    public static void main(String [] a){
        JFrame frame = new JFrame("MoveableTest");
        frame.setSize(1000, 500);


        final MoveableShape shape = new MarShape(0, 0, 100);
        ShapeIcon shapeIcon = new ShapeIcon(700, 400, shape);
        final JLabel label = new JLabel(shapeIcon);

        frame.getContentPane().add(label) ;
        frame.setVisible(true);

        Timer t = new Timer(100, new ActionListener(){
            public void actionPerformed(ActionEvent e){
                shape.move(10, 4);
                label.repaint();
            }
        });

        t.start();


    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?