|
-
April 30th, 2000, 05:45 PM
#1
arrays
why does this sample applet not work? anything wrong with the array declaration??
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class dictionary extends Applet
{
TextField s;
int row=4;
int col=4;
//private String[][] dict = new String;
String[][] dict=new String[row][col];
dict[0][0]="man";
dict[0][1]="book";
dict[0][2]="girl";
dict[0][3]="pen";
dict[1][0]="homme";
dict[1][1]="livre";
dict[1][2]="fille";
dict[1][3]="stylo";
s=new TextField(8);
add(s);
s.addActionListener(this);
public void actionPerformed (ActionEvent e) {
// event handling for event comes from the textfield
if (e.getSource() == s) {
Graphics g = getGraphics(); // u
}
for (int s=0;(!dict[s].column.equals(s))
&&
(!dict[s].column.equals("END"));
s++)
{}
if (dict(s).column.equals("END"))
{
g.drawString("Word not found",10,10);
else
g.drawString("The French word for"+s+"is"+dict[s][(row+1)],10,10);
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|