So Im trying to challenge myself and create a simple word processor application. I'm currently setting up the keyboard and having some trouble with the keys. I have a String array with each of the letters of the alphabet and want to place them onto the buttons.
I have this at the moment:
String FirstRow [] = {"q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"};
for(int i = 0; i < 40; i++)
{
if(i < 10)
{
JButton btn = new JButton();
Nums.add(btn);
btn.setText("" + Num);
Num++;
}
else
{
JButton btn1 = new JButton ();
Nums.add(btn1);
btn1.setText("" + FirstRow[n]);
n++;
}
}
Without the else section of the if statement it works fine placing numbers into the first row. When I try to place the letters however, I get an out of bounds exception and Im not sure how to fix this.