I've succeeded in showing the letters on the keys of the piano, but I want to make the font a bit bigger.
import greenfoot.*; // (World, Actor, [code]import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
import java.awt.*;
import java.lang.*;
/**
* A piano that can be played with the computer keyboard.
*
* @author: M. Kolling
* @version: 0.4
*/
public class Piano extends World
{
private String[] whiteKeys =
{"z", "x", "c", "v", "b", "n", "m", "s", "d", "f", "g", "h", "j", "k"};
private String[] whiteNotes =
{"2a", "2b", "3c", "3d", "3e", "3f", "3g", "3a", "3b", "4c", "4d", "4e", "4f", "4g" };
private String[] blackKeys =
{ "`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=" };
private String[] blackNotes =
{ "2a#", "", "3c#", "3d#", "", "3f#", "3g#", "3a#", "", "4c#", "4d#", "", "4f#"};
/**
* Make the piano. This means mostly, apart from defining the size,
* making the keys and placing them into the world.
*/
public Piano()
{
super(927, 340, 1);
makeKeys();
}
/**
* Create the piano keys and place them in the world.
*/
private void makeKeys()
{
for(int i = 0; i < whiteKeys.length; i++)
{
Key key = new Key(whiteKeys[i], whiteNotes[i] + ".wav");
addObject(key, 54 + (i*63), 140);
//showText(whiteKeys[i],54 + (i*63), 250);
}
for(int i = 0; i < whiteKeys.length-1; i++)
{
if(blackKeys[i] == "1" || blackKeys[i]== "4" || blackKeys[i] =="8" || blackKeys[i] =="-")
{
i++;
}
blackKey key = new blackKey(blackKeys[i], blackNotes[i] + ".wav");
addObject(key, 85 + (i*63), 86);
showText(blackKeys[i], 85 + (i*63), 140);
}
}
}
