home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 May / comcd0502.iso / homepage / javaspecial / 05_01 / Xylophone / Xylophone.java < prev   
Encoding:
Java Source  |  1999-11-17  |  17.0 KB  |  761 lines

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.awt.image.*;
  4. import java.net.*;
  5. import java.applet.*;
  6.  
  7. public class Xylophone extends Applet implements MouseMotionListener    {
  8.     static Image xyloImage, malletImage, mdImage, curImage, trebleClefImage, eighthImage, eighthImage2;
  9.     static AudioClip[] acArray;
  10.     static int mx=0, my=0;
  11.     static int curFloor=0, curCeiling=0;
  12.     static int curNote;
  13.     static SongSaver ss;
  14.     static Button playButton, stopButton, deleteButton, deleteLastButton; //play/pause are integrated
  15.     static Choice rhythmChoice, tempoChoice;
  16. //    static MouseListener ml;
  17.     static XyloListener ml;
  18.     static boolean up=true;
  19.     public void init()    {
  20.         setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  21.         acArray=new AudioClip[15];
  22.         xyloImage=getImage(getCodeBase(), "xylo.jpg");
  23.         malletImage=getImage(getCodeBase(), "mallet.gif");
  24.         mdImage=getImage(getCodeBase(), "mallet_down.gif");
  25.         trebleClefImage=getImage(getCodeBase(), "treble_clef.gif");
  26.         eighthImage=getImage(getCodeBase(), "eighth_note.gif");
  27.         eighthImage2=getImage(getCodeBase(), "eighth_note2.gif");
  28.         curImage=malletImage;
  29.         ss=new SongSaver();
  30.         playButton=new Button("Play");
  31.         stopButton=new Button("Stop");
  32.         deleteButton=new Button("Delete All");
  33.         deleteLastButton=new Button("Delete Last Note");
  34.         rhythmChoice=new Choice();
  35.         rhythmChoice.addItem("Quarter Note");
  36.         rhythmChoice.addItem("Eighth Note");
  37.         rhythmChoice.addItem("Sixteenth Note");
  38.         tempoChoice=new Choice();
  39.         tempoChoice.addItem("100 beats per minute");
  40.         tempoChoice.addItem("80 beats per minute");
  41.         tempoChoice.addItem("60 beats per minute");
  42.         add(playButton);
  43.         add(stopButton);
  44.         add(deleteLastButton);
  45.         add(deleteButton);
  46.         add(rhythmChoice);
  47.         add(tempoChoice);
  48.         try {
  49.             acArray[0]=getAudioClip(getCodeBase(), "x0.au");  
  50.             acArray[1]=getAudioClip(getCodeBase(), "x1.au");
  51.             acArray[2]=getAudioClip(getCodeBase(), "x2.au");
  52.             acArray[3]=getAudioClip(getCodeBase(), "x3.au");
  53.             acArray[4]=getAudioClip(getCodeBase(), "x4.au");
  54.             acArray[5]=getAudioClip(getCodeBase(), "x5.au");
  55.             acArray[6]=getAudioClip(getCodeBase(), "x6.au");
  56.             acArray[7]=getAudioClip(getCodeBase(), "x7.au");
  57.             acArray[8]=getAudioClip(getCodeBase(), "x8.au");
  58.             acArray[9]=getAudioClip(getCodeBase(), "x9.au");
  59.             acArray[10]=getAudioClip(getCodeBase(), "x10.au");
  60.             acArray[11]=getAudioClip(getCodeBase(), "x11.au");
  61.             acArray[12]=getAudioClip(getCodeBase(), "x12.au");
  62.             acArray[13]=getAudioClip(getCodeBase(), "x13.au");
  63.             acArray[14]=getAudioClip(getCodeBase(), "x14.au");
  64.         }    catch(Exception e)    {System.out.println("ALL FILES MUST BE IN THE SAME DIRECTORY");}
  65.         addMouseMotionListener(this);
  66.         ml=new XyloListener(this);
  67. //        ml=new MouseAdapter()    {
  68. //    public void mousePressed(MouseEvent e)    {
  69. //        int x=e.getX();
  70. //        int y=e.getY();
  71. //    if (y<233)    {
  72. //        if (x<60)    {
  73. //            curFloor=-1;    //negative denotes N/A
  74. //            curCeiling=60;
  75. //        }
  76. //        else if (x<93)    {
  77. //            curFloor=60;
  78. //            curCeiling=93;
  79. //        //    curNote=0;
  80. //            if ((y<233) && (y>0))    {
  81. //                acArray[0].play();
  82. //                ss.addNote(0);
  83. //            }
  84. //        }
  85. //        else if (x<125)    {
  86. //            curFloor=93;
  87. //            curCeiling=125;
  88. //        //    curNote=1;
  89. //            if ((y<233) && (y>0))    {
  90. //                acArray[1].play();
  91. //                ss.addNote(1);
  92. //            }
  93. //        }
  94. //        else if (x<158)    {
  95. //            curFloor=125;
  96. //            curCeiling=158;
  97. //            //curNote=2;
  98. //            if ((y<223) && (y>0))    {
  99. //                acArray[2].play();
  100. //                ss.addNote(2);
  101. //            }
  102. //        }
  103. //        else if (x<191)    {
  104. //            curFloor=158;
  105. //            curCeiling=191;
  106. //            //curNote=3;
  107. //            if ((y<220) && (y>0))    {
  108. //                acArray[3].play();
  109. //                ss.addNote(3);
  110. //            }
  111. //        }
  112. //        else if (x<223)    {
  113. //            curFloor=191;
  114. //            curCeiling=223;
  115. //    //        curNote=4;
  116. //            if ((y<218) && (y>0))    {
  117. //                acArray[4].play();
  118. //                ss.addNote(4);
  119. //            }
  120. //        }
  121. //        else if (x<257)    {
  122. //            curFloor=223;
  123. //            curCeiling=257;
  124. //        //    curNote=5;
  125. //            if ((y<215) && (y>0))    {
  126. //                acArray[5].play();
  127. //                ss.addNote(5);
  128. //            }
  129. //        }
  130. //        else if (x<289)    {
  131. //            curFloor=257;
  132. //            curCeiling=289;
  133. //            if ((y<210) && (y>0))    {
  134. //                acArray[6].play();
  135. //                ss.addNote(6);
  136. //            }
  137. //        }
  138. //        else if (x<322)    {
  139. //            curFloor=289;
  140. //            curCeiling=322;
  141. //            if ((y<207) && (y>0))    {
  142. //                acArray[7].play();
  143. //                ss.addNote(7);
  144. //            }
  145. //        }
  146. //        else if (x<354)    {
  147. //            curFloor=322;
  148. //            curCeiling=354;
  149. //            if ((y<206) && (y>0))    {
  150. //                acArray[8].play();
  151. //                ss.addNote(8);
  152. //            }
  153. //        }
  154. //        else if (x<387)    {
  155. //            curFloor=354;
  156. //            curCeiling=387;
  157. //            if ((y<202) && (y>0))    {
  158. //                acArray[9].play();
  159. //                ss.addNote(9);
  160. //            }
  161. //        }
  162. //        else if (x<416)    {
  163. //            curFloor=387;
  164. //            curCeiling=416;
  165. //            if ((y<197) && (y>0))    {
  166. //                acArray[10].play();
  167. //                ss.addNote(10);
  168. //            }
  169. //        }
  170. //        else if (x<448)    {
  171. //            curFloor=416;
  172. //            curCeiling=448;
  173. //            if ((y<194) && (y>0))    {
  174. //                acArray[11].play();
  175. //                ss.addNote(11);
  176. //            }
  177. //        }
  178. //        else if (x<478)    {
  179. //            curFloor=448;
  180. //            curCeiling=478;
  181. //            if ((y<192) && (y>0))    {
  182. //                acArray[12].play();
  183. //                ss.addNote(12);
  184. //            }
  185. //        }
  186. //        else if (x<508)    {
  187. //            curFloor=478;
  188. //            curCeiling=508;
  189. //            if ((y<189) && (y>25))    {
  190. //                acArray[13].play();
  191. //                ss.addNote(13);
  192. //            }
  193. //        }
  194. //        else if (x<538)    {
  195. //            curFloor=508;
  196. //            curCeiling=538;
  197. //            if ((y<187) && (y>29))    {
  198. //                acArray[14].play();
  199. //                ss.addNote(14);
  200. //            }
  201. //        }
  202. //        else    {
  203. //            curFloor=538;
  204. //            curCeiling=1601;
  205. //        }
  206. //        curImage=mdImage;
  207. //        repaint(mx, my, 37, 290);
  208. //        repaint(0,233, 575, 85);
  209. //    }
  210. //    else    {
  211. //        if ((y>=236) && (y<241))    {
  212. //            ss.addNote(14);
  213. //            acArray[14].play();
  214. //        }
  215. //        else if (y<246)    {
  216. //            ss.addNote(13);
  217. //            acArray[13].play();
  218. //        }
  219. //        else if (y<251)    {
  220. //            ss.addNote(12);
  221. //            acArray[12].play();
  222. //        }
  223. //        else if (y<256)    {
  224. //            ss.addNote(11);
  225. //            acArray[11].play();
  226. //        }
  227. //        else if (y<261)    {
  228. //            ss.addNote(10);
  229. //            acArray[10].play();
  230. //        }
  231. //        else if (y<266)    {
  232. //            ss.addNote(9);
  233. //            acArray[9].play();
  234. //        }
  235. //        else if (y<271)    {
  236. //            ss.addNote(8);
  237. //            acArray[8].play();
  238. //        }
  239. //        else if (y<276)    {
  240. //            ss.addNote(7);
  241. //            acArray[7].play();
  242. //        }
  243. //        else if (y<281)    {
  244. //            ss.addNote(6);
  245. //            acArray[6].play();
  246. //        }
  247. //        else if (y<286)    {
  248. //            ss.addNote(5);
  249. //            acArray[5].play();
  250. //        }
  251. //        else if (y<291)    {
  252. //            ss.addNote(4);
  253. //            acArray[4].play();
  254. //        }
  255. //        else if (y<296)    {
  256. //            ss.addNote(3);
  257. //            acArray[3].play();
  258. //        }
  259. //        else if (y<301)    {
  260. //            ss.addNote(2);
  261. //            acArray[2].play();
  262. //        }
  263. //        else if (y<306)    {
  264. //            ss.addNote(1);
  265. //            acArray[1].play();
  266. //        }
  267. //        else if (y<311)    {
  268. //            ss.addNote(0);
  269. //            acArray[0].play();
  270. //        }
  271. //        repaint(0,233, 575, 85);
  272. //    }
  273. //    }
  274. //    public void mouseReleased(MouseEvent e)    {
  275. //        curImage=malletImage;
  276. //        repaint(mx, my, 37, 290);
  277. //    }
  278.  //   public void mouseClicked(MouseEvent e) {
  279.   //  }
  280.    // public void mouseEntered(MouseEvent e) {
  281.     //    int y=e.getY();
  282.     //    if (y>233)    {
  283.     //        if (up)    {
  284.     //            up=false;
  285.     //            setCursor(new Cursor(Cursor.HAND_CURSOR));
  286.     //        }
  287.     //    }
  288.     //    else    {
  289.     //        if (!up)    {
  290.     //            up=true;
  291.     //            setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  292.     //        }
  293.     //    }
  294.     //    repaint();
  295.   //  }
  296. //
  297.  //   public void mouseExited(MouseEvent e) {
  298. //        repaint();
  299.  //   }
  300. //};
  301.         addMouseListener(ml);
  302.     }
  303.     public void paint(Graphics g)    {
  304.         g.drawImage(xyloImage, 0,0,this);
  305.         g.drawImage(trebleClefImage, 0,250,this);
  306.         g.setColor(Color.black);
  307.         g.drawLine(0,258,575,258);
  308.         g.drawLine(0,268,575,268);
  309.         g.drawLine(0,278,575,278);
  310.         g.drawLine(0,288,575,288);
  311.         g.drawLine(0,298,575,298);
  312.         for(int i=0;i<20;i++)    {
  313.             if (ss.noteList[i]!=0)    {
  314.                 g.fillOval(50+25*i, 303-5*(ss.noteList[i]-1)+1, 12, 9);
  315.                 if (ss.noteList[i]==1)
  316.                     g.drawLine(50+25*i-3,308,50+25*i+15,308);
  317.                 else if (ss.noteList[i]>12)    {
  318.                     g.drawLine(50+25*i-3,248,50+25*i+15,248);
  319.                     if (ss.noteList[i]==15)
  320.                         g.drawLine(50+25*i-3,238,50+25*i+15,238);
  321.                 }
  322.                 if (ss.noteList[i]<7)    {
  323.                     g.drawLine(62+25*i, 303-5*(ss.noteList[i]-1)+5, 62+25*i, 303-5*(ss.noteList[i]-1)-28);
  324.                     switch (ss.rhythmList[i])    {
  325.                         case 2: g.drawImage(eighthImage, 62+25*i, 303-5*(ss.noteList[i]-1)-20, this);
  326.                         case 1: g.drawImage(eighthImage, 62+25*i, 303-5*(ss.noteList[i]-1)-28, this);
  327.                     }
  328.                 }
  329.                 else    {
  330.                     g.drawLine(50+25*i, 303-5*(ss.noteList[i]-1)+5, 50+25*i, 303-5*(ss.noteList[i]-1)+38);
  331.                     switch (ss.rhythmList[i])    {
  332.                         case 2: g.drawImage(eighthImage2, 50+25*i-6, 303-5*(ss.noteList[i]-1)+12, this);
  333.                         case 1: g.drawImage(eighthImage2, 50+25*i-6, 303-5*(ss.noteList[i]-1)+20, this);
  334.                     }
  335.                 }
  336.             }
  337.         }
  338.         if (up)    {
  339.             g.drawImage(curImage, mx, my, this);
  340.         }
  341.     }
  342.     public void mouseMoved(MouseEvent e)  {
  343.         int x=e.getX();
  344.         int y=e.getY();
  345.         if (y>233)    {
  346.             if (up)    {
  347.                 up=false;
  348.                 setCursor(new Cursor(Cursor.HAND_CURSOR));
  349.                 repaint();
  350.             }
  351.         }
  352.         else    {
  353.             if (!up)    {
  354.                 up=true;
  355.                 setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  356.             }
  357.         }
  358.         int tempY=0;
  359.         if (y-15-my>0)
  360.         tempY=my;
  361.         else
  362.         tempY=y-16;
  363.         if (y<233)    {
  364.             if (x-mx>18)    {
  365.                 repaint(mx, tempY, x-mx+20, 290);
  366.             }
  367.             else    {
  368.                 repaint(x-18,tempY,54+mx-x,290);
  369.             }
  370.         }
  371.         mx=x-18;
  372.         my=y-15;
  373.     }
  374.     public void mouseDragged(MouseEvent e)  {
  375.         int x=e.getX();
  376.         int y=e.getY();
  377.         if (y>233)    {
  378.             if (up)    {
  379.                 up=false;
  380.                 setCursor(new Cursor(Cursor.HAND_CURSOR));
  381.                 repaint();
  382.             }
  383.         }
  384.         else    {
  385.             if (!up)    {
  386.                 up=true;
  387.                 setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  388.             }
  389.         }
  390.         int tempY=0;
  391.         if (y-15-my>0)
  392.             tempY=my;
  393.         else
  394.             tempY=y-16;
  395.         if (y<233)    {
  396.             if (x-mx>18)    {
  397.                 repaint(mx, tempY, x-mx+20, 290);
  398.             }
  399.             else    {
  400.                 repaint(x-18,tempY,54+mx-x,290);
  401.             }
  402.         }
  403.         mx=x-18;
  404.         my=y-15;
  405.         if (((e.getX()>curCeiling)||(e.getX()<curFloor))&&(e.getY()<233))
  406.             ml.mousePressed(e);
  407.     }
  408.     public void destroy()    {
  409.         removeMouseMotionListener(this);
  410.     }
  411.     public boolean action(Event e, Object arg)    {
  412.         if (e.target instanceof Button)    {
  413.             if (((Button)e.target).equals(playButton))    {
  414.                 if (playButton.getLabel().equals(new String("Play")))    {
  415.                     playButton.setLabel("Pause");
  416.                     ss.play();
  417.                 }
  418.                 else    {
  419.                     ss.pause();
  420.                 }
  421.             }
  422.             else if (((Button)e.target).equals(stopButton))    {
  423.                 ss.stop();
  424.             }
  425.             else if (((Button)e.target).equals(deleteButton))    {
  426.                 ss.stop();
  427.                 ss.erase();
  428.                 repaint(0,233,600,150);
  429.             }
  430.             else if (((Button)e.target).equals(deleteLastButton))    {
  431.                 ss.stop();
  432.                 ss.eraseLast();
  433.                 repaint(0,233,600,150);
  434.             }
  435.         }
  436.         return super.action(e, arg);
  437.     }
  438. }
  439. public class SongSaver    {
  440.     int[] noteList, rhythmList;
  441.     int currentSlot;
  442.     static int currentPlayingNote;
  443.     static boolean paused;
  444.     static boolean stopped;
  445.     SongSaver()    {
  446.         noteList=new int[20];
  447.         rhythmList=new int[20];
  448.         currentSlot=0;
  449.         paused=false;
  450.         currentPlayingNote=0;
  451.     }
  452.     public void play()    {
  453.         paused=false;
  454.         new PlayThread(this).start();
  455.     }
  456.     public void pause()    {
  457.         paused=true;
  458.     }
  459.     public void stop()    {
  460.         stopped=true;
  461.         paused=true;
  462.     }
  463.     public void addNote(int n)    {
  464.         if (noteList[19]==0)    {
  465.             noteList[currentSlot]=n+1;
  466.             rhythmList[currentSlot]=Xylophone.rhythmChoice.getSelectedIndex();
  467.             currentSlot++;
  468.         }
  469.     }
  470.     public void erase()    {
  471.         noteList=new int[20];
  472.         currentSlot=0;
  473.     }
  474.     public void eraseLast()    {
  475.         currentSlot--;
  476.         int i;
  477.         for (i=-1;i<19;i++)    {
  478.             if (noteList[i+1]==0)    {
  479.                 noteList[i]=0;
  480.                 i=20;
  481.             }
  482.         }
  483.         if (i==19)    {
  484.             noteList[19]=0;
  485.         }
  486.     }
  487. }
  488. public class PlayThread extends Thread    {
  489.     int[] noteList, rhythmList;
  490.     int currentSlot;
  491.     int currentPlayingNote;
  492.     PlayThread(SongSaver ss)    {
  493.         this.noteList=ss.noteList;
  494.         this.rhythmList=ss.rhythmList;
  495.         this.currentPlayingNote=ss.currentPlayingNote;
  496.     }
  497.     public void run()    {
  498.             int s;
  499.             for (int i=this.currentPlayingNote;(i<20)&&(noteList[i]!=0);i++)    {
  500.                 Xylophone.acArray[noteList[i]-1].play();
  501.                 s=rhythmList[i];
  502.                 if (s==0)
  503.                     s=100*(Xylophone.tempoChoice.getSelectedIndex()*2+6)-80;
  504.                 else if (s==1)
  505.                     s=50*(Xylophone.tempoChoice.getSelectedIndex()*2+6)-80;
  506.                 else
  507.                     s=25*(Xylophone.tempoChoice.getSelectedIndex()*2+6)-80;
  508.                 try    {
  509.                     Thread.sleep(s);
  510.                 } catch(Exception e)    {}
  511.                 if (SongSaver.paused)    {
  512.                     currentPlayingNote=i;
  513.                     i=20;
  514.                 }
  515.             }
  516.         if (SongSaver.stopped)    {
  517.             SongSaver.currentPlayingNote=0;
  518.             SongSaver.stopped=false;
  519.         }
  520.         else
  521.             SongSaver.currentPlayingNote=this.currentPlayingNote+1;
  522.         Xylophone.playButton.setLabel("Play");
  523.         if (!SongSaver.paused)
  524.             SongSaver.currentPlayingNote=0;
  525.     }
  526. }
  527. public class XyloListener implements MouseListener    {
  528.     Xylophone xylo;
  529.     XyloListener(Xylophone xylo)    {
  530.         super();
  531.         this.xylo=xylo;
  532.     }
  533.     public void mousePressed(MouseEvent e)    {
  534.         int x=e.getX();
  535.         int y=e.getY();
  536.     if (y<233)    {
  537.         if (x<60)    {
  538.             Xylophone.curFloor=-1;    //negative denotes N/A
  539.             Xylophone.curCeiling=60;
  540.         }
  541.         else if (x<93)    {
  542.             Xylophone.curFloor=60;
  543.             Xylophone.curCeiling=93;
  544.             if ((y<233) && (y>0))    {
  545.                 Xylophone.acArray[0].play();
  546.                 Xylophone.ss.addNote(0);
  547.             }
  548.         }
  549.         else if (x<125)    {
  550.             Xylophone.curFloor=93;
  551.             Xylophone.curCeiling=125;
  552.             if ((y<233) && (y>0))    {
  553.                 Xylophone.acArray[1].play();
  554.                 Xylophone.ss.addNote(1);
  555.             }
  556.         }
  557.         else if (x<158)    {
  558.             Xylophone.curFloor=125;
  559.             Xylophone.curCeiling=158;
  560.             if ((y<223) && (y>0))    {
  561.                 Xylophone.acArray[2].play();
  562.                 Xylophone.ss.addNote(2);
  563.             }
  564.         }
  565.         else if (x<191)    {
  566.             Xylophone.curFloor=158;
  567.             Xylophone.curCeiling=191;
  568.             if ((y<220) && (y>0))    {
  569.                 Xylophone.acArray[3].play();
  570.                 Xylophone.ss.addNote(3);
  571.             }
  572.         }
  573.         else if (x<223)    {
  574.             Xylophone.curFloor=191;
  575.             Xylophone.curCeiling=223;
  576.             if ((y<218) && (y>0))    {
  577.                 Xylophone.acArray[4].play();
  578.                 Xylophone.ss.addNote(4);
  579.             }
  580.         }
  581.         else if (x<257)    {
  582.             Xylophone.curFloor=223;
  583.             Xylophone.curCeiling=257;
  584.             if ((y<215) && (y>0))    {
  585.                 Xylophone.acArray[5].play();
  586.                 Xylophone.ss.addNote(5);
  587.             }
  588.         }
  589.         else if (x<289)    {
  590.             Xylophone.curFloor=257;
  591.             Xylophone.curCeiling=289;
  592.             if ((y<210) && (y>0))    {
  593.                 Xylophone.acArray[6].play();
  594.                 Xylophone.ss.addNote(6);
  595.             }
  596.         }
  597.         else if (x<322)    {
  598.             Xylophone.curFloor=289;
  599.             Xylophone.curCeiling=322;
  600.             if ((y<207) && (y>0))    {
  601.                 Xylophone.acArray[7].play();
  602.                 Xylophone.ss.addNote(7);
  603.             }
  604.         }
  605.         else if (x<354)    {
  606.             Xylophone.curFloor=322;
  607.             Xylophone.curCeiling=354;
  608.             if ((y<206) && (y>0))    {
  609.                 Xylophone.acArray[8].play();
  610.                 Xylophone.ss.addNote(8);
  611.             }
  612.         }
  613.         else if (x<387)    {
  614.             Xylophone.curFloor=354;
  615.             Xylophone.curCeiling=387;
  616.             if ((y<202) && (y>0))    {
  617.                 Xylophone.acArray[9].play();
  618.                 Xylophone.ss.addNote(9);
  619.             }
  620.         }
  621.         else if (x<416)    {
  622.             Xylophone.curFloor=387;
  623.             Xylophone.curCeiling=416;
  624.             if ((y<197) && (y>0))    {
  625.                 Xylophone.acArray[10].play();
  626.                 Xylophone.ss.addNote(10);
  627.             }
  628.         }
  629.         else if (x<448)    {
  630.             Xylophone.curFloor=416;
  631.             Xylophone.curCeiling=448;
  632.             if ((y<194) && (y>0))    {
  633.                 Xylophone.acArray[11].play();
  634.                 Xylophone.ss.addNote(11);
  635.             }
  636.         }
  637.         else if (x<478)    {
  638.             Xylophone.curFloor=448;
  639.             Xylophone.curCeiling=478;
  640.             if ((y<192) && (y>0))    {
  641.                 Xylophone.acArray[12].play();
  642.                 Xylophone.ss.addNote(12);
  643.             }
  644.         }
  645.         else if (x<508)    {
  646.             Xylophone.curFloor=478;
  647.             Xylophone.curCeiling=508;
  648.             if ((y<189) && (y>25))    {
  649.                 Xylophone.acArray[13].play();
  650.                 Xylophone.ss.addNote(13);
  651.             }
  652.         }
  653.         else if (x<538)    {
  654.             Xylophone.curFloor=508;
  655.             Xylophone.curCeiling=538;
  656.             if ((y<187) && (y>29))    {
  657.                 Xylophone.acArray[14].play();
  658.                 Xylophone.ss.addNote(14);
  659.             }
  660.         }
  661.         else    {
  662.             Xylophone.curFloor=538;
  663.             Xylophone.curCeiling=1601;
  664.         }
  665.         Xylophone.curImage=Xylophone.mdImage;
  666.         xylo.repaint(Xylophone.mx, Xylophone.my, 37, 290);
  667.         xylo.repaint(0,233, 575, 85);
  668.     }
  669.     else    {
  670.         if (y<236)
  671.             ;
  672.         else if (y<241)    {
  673.             Xylophone.ss.addNote(14);
  674.             Xylophone.acArray[14].play();
  675.         }
  676.         else if (y<246)    {
  677.             Xylophone.ss.addNote(13);
  678.             Xylophone.acArray[13].play();
  679.         }
  680.         else if (y<251)    {
  681.             Xylophone.ss.addNote(12);
  682.             Xylophone.acArray[12].play();
  683.         }
  684.         else if (y<256)    {
  685.             Xylophone.ss.addNote(11);
  686.             Xylophone.acArray[11].play();
  687.         }
  688.         else if (y<261)    {
  689.             Xylophone.ss.addNote(10);
  690.             Xylophone.acArray[10].play();
  691.         }
  692.         else if (y<266)    {
  693.             Xylophone.ss.addNote(9);
  694.             Xylophone.acArray[9].play();
  695.         }
  696.         else if (y<271)    {
  697.             Xylophone.ss.addNote(8);
  698.             Xylophone.acArray[8].play();
  699.         }
  700.         else if (y<276)    {
  701.             Xylophone.ss.addNote(7);
  702.             Xylophone.acArray[7].play();
  703.         }
  704.         else if (y<281)    {
  705.             Xylophone.ss.addNote(6);
  706.             Xylophone.acArray[6].play();
  707.         }
  708.         else if (y<286)    {
  709.             Xylophone.ss.addNote(5);
  710.             Xylophone.acArray[5].play();
  711.         }
  712.         else if (y<291)    {
  713.             Xylophone.ss.addNote(4);
  714.             Xylophone.acArray[4].play();
  715.         }
  716.         else if (y<296)    {
  717.             Xylophone.ss.addNote(3);
  718.             Xylophone.acArray[3].play();
  719.         }
  720.         else if (y<301)    {
  721.             Xylophone.ss.addNote(2);
  722.             Xylophone.acArray[2].play();
  723.         }
  724.         else if (y<306)    {
  725.             Xylophone.ss.addNote(1);
  726.             Xylophone.acArray[1].play();
  727.         }
  728.         else if (y<311)    {
  729.             Xylophone.ss.addNote(0);
  730.             Xylophone.acArray[0].play();
  731.         }
  732.         xylo.repaint(0,233, 575, 85);
  733.     }
  734.     }
  735.     public void mouseReleased(MouseEvent e)    {
  736.         Xylophone.curImage=Xylophone.malletImage;
  737.         xylo.repaint(Xylophone.mx, Xylophone.my, 37, 290);
  738.     }
  739.     public void mouseClicked(MouseEvent e) {
  740.     }
  741.     public void mouseEntered(MouseEvent e) {
  742.         int y=e.getY();
  743.         if (y>233)    {
  744.             if (Xylophone.up)    {
  745.                 Xylophone.up=false;
  746.                 xylo.setCursor(new Cursor(Cursor.HAND_CURSOR));
  747.             }
  748.         }
  749.         else    {
  750.             if (!Xylophone.up)    {
  751.                 Xylophone.up=true;
  752.                 xylo.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
  753.             }
  754.         }
  755.         xylo.repaint();
  756.     }
  757.  
  758.     public void mouseExited(MouseEvent e) {
  759.         xylo.repaint();
  760.     }
  761. }