Variable value not being stored

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarta
    New Member
    • Jun 2010
    • 2

    Variable value not being stored

    Hello,

    I am a newbie at programming and have a question. The variable fnh is not being stored in the fullFNH in the second file, only in fnh in the first file. Can someone suggest me what I could be doing wrong? Thanks in advance.


    // AlladinLamp.jav a

    Code:
    import statements go here
    
    public class AlladinLamp  {
    
       int fnh;
       JComboBox runners;
       other variables go here
    
       actionListener and other methods go here, including
    
       public int getFNH()  { return fnh; }
    
       ActionListener runnersActionListener = new ActionListener()  {
              @Override
              public void actionPerformed( ActionEvent e ) {
                 String  runnersNumber = ( String )runners.getSelectedItem();
                 fnh = Integer.parseInt( runnersNumber );          
                 hNam = new String[ fnh ];
                 hNum = new int[ fnh ];
                 hVal = new int[ fnh ];
                 jtxt = new JTextField[ fnh ];
                 reducedFNH = reduce( fnh );                
               }
       };
    
    
    
       public AlladinLamp()  {
    
          gui built here...
    
          String[] numberOfRunners = { "8", "9", "10", "11", "12",
                                    "13", "14", "15", "16", "17",
                                    "18", "19", "20", "21", "22" };
    
          runners = new JComboBox( numberOfRunners );
          runners.setMaximumRowCount(5); 
    
    
          runners.addActionListener( runnersActionListener );
    
          ...
    }
    
    public static void main( String args[] )  {
    
       SwingUtilities.invokeLater( new Runnable()  {
                @Override
                public void run()  {
                    AlladinLamp lamp = new AlladinLamp();                 
                }
            });
    
    }
     
    
    // Process.java
    
    import statements go here
    
    public class Processes  {
    
    int fullNH;
    AlladinLamp lamp;
    
    public Process()  {
    
      lamp = new AlladinLamp();
      fullNH = lamp.getFNH();
    
      ...
    
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Post the actual code that you used. What you posted doesn't even compile.

    Comment

    Working...