PDA

View Full Version : Java Question




RevK
Nov 10, 2007, 07:47 PM
Hi macrumors users:

I have this code that is supposed to read data into an int, then convert to a string and set a JLabel to that string:

Scanner ins = null;
try
{
File myFile = new File(PATH + FILE_NAME);
// let's see if we have the right file.
// let's check the path.
System.out.println(myFile.getAbsolutePath());
ins = new Scanner(myFile);
}
catch (FileNotFoundException ex)
{
ex.printStackTrace();
}
int ni = ins.nextInt();
String stringni = Integer.toString(ni);

currentb.setText(stringni);

For some reason, the currentb label will not change to the stringni string. Any ideas?



therevolution
Nov 10, 2007, 09:31 PM
Try calling repaint() on the container that contains the JLabel, perhaps?