the red dot for this program is not showing for some reason. any help will be greatly appreciated
Code:import java.awt.*;
import java.applet.*;
import javax.sound.midi.*;
import javax.sound.midi.Synthesizer;
import javax.swing.text.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.*;
public class Piano extends JApplet
{
boolean hit = false;
int soundnumber;
int x;
int y;
int[] keyEdge = {54, 74, 90, 102, 118, 138, 158, 174, 186, 202, 214, 230, 250, 270,
286, 298, 314, 334, 354, 370, 382, 398, 410, 426, 447};
int soundNumber;
int[] whiteKey = {0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23};
int redotx;
boolean isWhite;
boolean record = false;
int a[] = new int[100];
int z = 0;
Keyboard kBoard;
Synthesizer synthesizer;
MidiChannel channel;
ClickMouseListenerClass mouseHandler;
ClickKeyListenerClass keyHandler;
RecordButtonListenerClass recordListener;
PlayRecordedButtonListenerClass playRecordedListener;
JButton recordButton;
JButton playButton;
BufferedImage myPicture;
Dot rdot;
public void init()
{
try{
myPicture = ImageIO.read(new File("piano.gif"));
}
catch(IOException ie){}
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
Container c = getContentPane();
Box all = Box.createVerticalBox();
Box top = Box.createHorizontalBox();
Box bottom = Box.createHorizontalBox();
recordButton = new JButton("Record");
playButton = new JButton("Play");
c.setLayout(new FlowLayout());
this.rdot = new Dot();
top.add(this.rdot);
top.add(picLabel);
all.add(top);
all.add(Box.createVerticalStrut(25));
bottom.add(recordButton);
bottom.add(playButton);
all.add(bottom);
c.add(all);
resize(500, 450);
kBoard = new Keyboard();
kBoard.setKeys();
kBoard.setSound();
try
{
synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
channel = synthesizer.getChannels()[0];
}
catch(MidiUnavailableException mue) {}
mouseHandler = new ClickMouseListenerClass(this);
this.addMouseListener(mouseHandler);
keyHandler = new ClickKeyListenerClass(this);
c.addKeyListener(keyHandler);
c.setFocusable(true);
recordListener = new RecordButtonListenerClass(this);
//recordButton = new JButton("Record");
recordButton.addActionListener(recordListener);
playRecordedListener = new PlayRecordedButtonListenerClass(this);
//playButton = new JButton("Play");
playButton.addActionListener(playRecordedListener);
}
public void paintComponent(Graphics g){
g.drawImage(myPicture, 0, 0, myPicture.getWidth(this), myPicture.getHeight(this), this);
}
public class Dot extends JPanel{
public void paintComponent(Graphics g){
paintdot(g);
System.out.println("y");
}
public void paintdot(Graphics g){
if(hit)
{
isWhite=false;
for(int i = 0; i < 14; i++){
if(whiteKey[i] == soundNumber){
isWhite=true;
}
}
if(isWhite){
g.setColor(Color.red);
redotx = 54;
for(int i = 0; i < 14; i++){
if(whiteKey[i] == soundNumber){
redotx = i*28+54+14;
}
}
g.fillOval(redotx - 4, 220, 10, 10);
}
else{
g.setColor(Color.red);
redotx = ((keyEdge[soundNumber + 1] + keyEdge[soundNumber])/2)+2;
g.fillOval(redotx - 4, 180, 10, 10);
}
}
System.out.println("dot"+redotx);
}
}
public void checkKey(char c)
{
String myKey[] = {"a","h","c","d","e","f","g"};
int mySound[] = {9,11,0,2,4,5,7};
String thePressedKey = "" + c;
for(int i = 0; i < 7; i++)
{
if(thePressedKey.equalsIgnoreCase(myKey[i]))
{
soundNumber=mySound[i];
hit = true;
int kt = kBoard.getSound(soundNumber);
play(kt);
if(record)
{
storeSong(kt);
}
repaint();
}
}
}
public void checkMouse(int x, int y)
{
int white;
hit = false;
if((x >= 54) && (y >= 116) && (x <= 447) && (y <= 235))
{
hit=true;
if(y > 208)
{
white = (x - 54)/28;
soundNumber = whiteKey[white];
}
else
{
for(int i = 0; i < 24; i++)
{
if((x > keyEdge[i]) && (x < keyEdge[i + 1]))
soundNumber = i;
}
}
int mt = kBoard.getSound(soundNumber);
play(mt);
if(record)
{
storeSong(mt);
}
}
repaint();
}
public void recordButtonOn()
{
record = true;
}
public void storeSong(int s)
{
a[z] = s;
System.out.println(a[z]);
z++;
}
public void playRecordedSong()
{
System.out.println("In play class");
//int length = a.length;
System.out.println("After play class" + z);
for(int i=0; i<z; i++)
{
int prs = a[i];
System.out.println("After play class in for loop" + prs);
play(prs);
repaint();
}
}
public void play(int note)
{
channel.noteOn(note, 50);
System.out.println("In play" + note);
try
{
Thread.sleep(200);
}
catch(InterruptedException ie) {}
channel.noteOff(note);
}
}

