Java Question

Discussion in 'Mac Programming' started by RevK, Nov 10, 2007.

  1. macrumors member

    Joined:
    Apr 26, 2004
    #1
    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:

    Code:
    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?
     
  2. macrumors 6502

    Joined:
    May 12, 2003
    #2
    Try calling repaint() on the container that contains the JLabel, perhaps?
     

Share This Page