⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeraction.java

📁 《Java与模式》一书的源代码
💻 JAVA
字号:
package com.javapatterns.observertimer.cursor;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.*;

public class TimerAction extends AbstractAction
{
    private int ind = 0;
    private Applet applet;

    public TimerAction(Applet applet)
    {
        this.applet = applet;
    }

    public void actionPerformed(ActionEvent e)
    {
        if (ind == 0)
        {
            drawCursor(Cursor.NE_RESIZE_CURSOR);
        }
        else if (ind == 1)
        {
            drawCursor(Cursor.N_RESIZE_CURSOR);
        }
        else if (ind == 2)
        {
            drawCursor(Cursor.NW_RESIZE_CURSOR);
        }
        else if (ind == 3)
        {
            drawCursor(Cursor.W_RESIZE_CURSOR);
        }
        else if (ind == 4)
        {
            drawCursor(Cursor.SW_RESIZE_CURSOR);
        }
        else if (ind == 5)
        {
            drawCursor(Cursor.S_RESIZE_CURSOR);
        }
        else if (ind == 6)
        {
            drawCursor(Cursor.SE_RESIZE_CURSOR);
        }
        else if (ind == 7)
        {
            drawCursor(Cursor.E_RESIZE_CURSOR);
            ind = -1;
        }

        ind++;
    }

    public void drawCursor(int cursorType)
    {
        applet.setCursor(Cursor.getPredefinedCursor(cursorType));
    }
}

⌨️ 快捷键说明

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