import java.awt.*; public class CursorTest extends java.applet.Applet { String[] cur = { "NW" , "W" , "SW" , "N" , "Move", "S" , "NE" , "E" , "SE" , "Cross", "Default", "Hand", "Text", "Wait", " " }; Color[] col = {Color.white,Color.cyan ,Color.lightGray,Color.blue ,Color.magenta, Color.red ,Color.green,Color.blue ,Color.yellow,Color.cyan , Color.gray ,Color.pink ,Color.orange ,Color.red ,Color.white }; int[] cursor = { Frame.NW_RESIZE_CURSOR, Frame.W_RESIZE_CURSOR, Frame.SW_RESIZE_CURSOR, Frame.N_RESIZE_CURSOR, Frame.MOVE_CURSOR, Frame.S_RESIZE_CURSOR, Frame.NE_RESIZE_CURSOR, Frame.E_RESIZE_CURSOR, Frame.SE_RESIZE_CURSOR, Frame.CROSSHAIR_CURSOR, Frame.DEFAULT_CURSOR, Frame.HAND_CURSOR, Frame.TEXT_CURSOR, Frame.WAIT_CURSOR, Frame.DEFAULT_CURSOR }; Object anchor; Frame applFrame; public void init() { anchor = getParent(); while (!(anchor instanceof Frame)) anchor = ((Component)anchor).getParent(); applFrame = (Frame)anchor; } public void paint(Graphics g) { setBackground(Color.white); g.setFont(new Font("Tahoma",Font.BOLD,12)); int k=0; int x,y; for (int i=0;i<5;i++){ for(int j=0;j<3;j++){ x=5+i*80; y=5+j*40; g.setColor(col[k]); g.fillRect(x,y,80,40); if (k < 14) { g.setColor(Color.black); g.drawRect(x-1,y-1,80,40); g.drawString(cur[k],x+20,y+15); } k++; } } } public boolean mouseMove(Event evt,int x_coor, int y_coor) { int x1,x2,y1,y2; int k=0; applFrame.setCursor(Frame.DEFAULT_CURSOR); a: for (int i=0;i<5;i++){ for(int j=0;j<3;j++){ x1=5+i*80; x2=x1+80; y1=5+j*40; y2=y1+40; if ((x_coor>=x1 && x_coor<=x2) && (y_coor>=y1 && y_coor<=y2) ) { applFrame.setCursor(cursor[k]); break a; } k++; } } return true; } }