473,473 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Variable value not being stored

2 New Member
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.java

Expand|Select|Wrap|Line Numbers
  1. import statements go here
  2.  
  3. public class AlladinLamp  {
  4.  
  5.    int fnh;
  6.    JComboBox runners;
  7.    other variables go here
  8.  
  9.    actionListener and other methods go here, including
  10.  
  11.    public int getFNH()  { return fnh; }
  12.  
  13.    ActionListener runnersActionListener = new ActionListener()  {
  14.           @Override
  15.           public void actionPerformed( ActionEvent e ) {
  16.              String  runnersNumber = ( String )runners.getSelectedItem();
  17.              fnh = Integer.parseInt( runnersNumber );          
  18.              hNam = new String[ fnh ];
  19.              hNum = new int[ fnh ];
  20.              hVal = new int[ fnh ];
  21.              jtxt = new JTextField[ fnh ];
  22.              reducedFNH = reduce( fnh );                
  23.            }
  24.    };
  25.  
  26.  
  27.  
  28.    public AlladinLamp()  {
  29.  
  30.       gui built here...
  31.  
  32.       String[] numberOfRunners = { "8", "9", "10", "11", "12",
  33.                                 "13", "14", "15", "16", "17",
  34.                                 "18", "19", "20", "21", "22" };
  35.  
  36.       runners = new JComboBox( numberOfRunners );
  37.       runners.setMaximumRowCount(5); 
  38.  
  39.  
  40.       runners.addActionListener( runnersActionListener );
  41.  
  42.       ...
  43. }
  44.  
  45. public static void main( String args[] )  {
  46.  
  47.    SwingUtilities.invokeLater( new Runnable()  {
  48.             @Override
  49.             public void run()  {
  50.                 AlladinLamp lamp = new AlladinLamp();                 
  51.             }
  52.         });
  53.  
  54. }
  55.  
  56.  
  57. // Process.java
  58.  
  59. import statements go here
  60.  
  61. public class Processes  {
  62.  
  63. int fullNH;
  64. AlladinLamp lamp;
  65.  
  66. public Process()  {
  67.  
  68.   lamp = new AlladinLamp();
  69.   fullNH = lamp.getFNH();
  70.  
  71.   ...
  72.  
  73. }
Mar 28 '13 #1
1 1380
r035198x
13,262 MVP
Post the actual code that you used. What you posted doesn't even compile.
Mar 28 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: harishg2 | last post by:
Hi, How to store a variable value for more than one executions. Ex: main() { int i=0; i++; printf("%d",i);
1
by: Boltar | last post by:
Hello, I am relatively new to C#. There is a particular address in memory on my computer that stores a string value. The address is 57E777. Does anyone know how I can retrieve the string...
1
by: Varadha | last post by:
Hi, I am declaring a variable static char Version_No = '1' in header file header.h In a application "app.exe", i am changing the value of the variable in to '2' In the same application i am...
3
by: Helpseeker | last post by:
Hi all, I have written a small code in which i declare a static int variable and increment its value by one each time i click on a button. actually i use the int variable value in a particular URL...
7
by: John Smith | last post by:
Hello, I have a simple question, I have a vb.net form with several buttons. If I store the name of a button in a variable.. Dim TheName as string TheName = ...
0
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value),...
9
by: Vbbeginner07 | last post by:
Want to change the value stored in the bold, it's a code to calculate the payroll. If txttr.Text = "" Then Form2.txttamt.Text = "" MsgBox "enter the tax rate", vbOKOnly, "ERROR" ...
1
by: pendem | last post by:
I mean can set a variable value in a script to be unchanged even after page reload? for example if i set a value of a global variable "val" to 2 ; so using onbeforeunload() or onunload(), i will...
3
by: sweetneel | last post by:
hi all, thanks in advance. I need a help , its urgent. I am developing a webapplication with maser page. there i have a lebel, control. i need to update its value from the content page, and only...
9
dsatino
by: dsatino | last post by:
I'm sure I've actually done this before, so why I can't figure this out now is annoying. I'm hoping someone can spark my memory here. Basically, I have 54 variable names stored in an array. I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.