AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

changing an int value across classes,kind of working :s

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Dilbert
Guest





PostPosted: Fri Nov 14, 2003 10:23 am    Post subject: changing an int value across classes,kind of working :s Reply with quote



Hi there, im using 2 classes for my program. base and gui.

in base, i have set: int size = 5;

and in gui, with the use of a comboBox, i have:

if (jComboBox.getSelectedIndex()==2 ) {

base.size = 8;

}

this compiles fine,and also runs fine.



The int size ... in my base class effects the way the program runs, and must
have a start value.

The idea is, the user selects index2 of the comboBox and it changes the int
size value from 5 - 8. If i use the comboBox at index2, no errors turn up,
yet it just doenst work.

Ive tried repaint(); but this didnt work either, anyone got any ideas?

Cheers



Back to top
Dave
Guest





PostPosted: Sat Nov 15, 2003 7:39 pm    Post subject: Re: changing an int value across classes,kind of working :s Reply with quote



Have you checked in the debugger if the value of your class attribute 'size'
is changed to 8 when it should? If this goes allright, the problem must be
somewhere else but I have insufficient information about what should happen
when it gets assigned value 8 to be of any help.

Regards,

Dave




---------------------------------------------------------------------
Computers, you can't live with them and you can't live without them.
---------------------------------------------------------------------
"Dilbert" <HaveNoSpamMail (AT) memail (DOT) com> wrote

Quote:
Hi there, im using 2 classes for my program. base and gui.

in base, i have set: int size = 5;

and in gui, with the use of a comboBox, i have:

if (jComboBox.getSelectedIndex()==2 ) {

base.size = 8;

}

this compiles fine,and also runs fine.



The int size ... in my base class effects the way the program runs, and
must
have a start value.

The idea is, the user selects index2 of the comboBox and it changes the
int
size value from 5 - 8. If i use the comboBox at index2, no errors turn up,
yet it just doenst work.

Ive tried repaint(); but this didnt work either, anyone got any ideas?

Cheers






Back to top
kevinc
Guest





PostPosted: Sat Nov 15, 2003 8:22 pm    Post subject: Re: changing an int value across classes,kind of working :s Reply with quote



Things that I would look at.

1) How are you checking the value of base after the GUI code has changed
the base.

2) Are you sure that the base instance that your GUI is changing is the
same base instance that you are inspecting after the GUI makes the change.

3) As an aside. NEVER,NEVER,NEVER have a class that publicy exposes it's
instance vars. use acessor/modifier method instead. This way. You
would be able to tell if a change was made to base.size, by using
base.setSize(int someVal){
System.out.println("Im changing my size to " + someVal);
}

Dave wrote:
Quote:
Have you checked in the debugger if the value of your class attribute 'size'
is changed to 8 when it should? If this goes allright, the problem must be
somewhere else but I have insufficient information about what should happen
when it gets assigned value 8 to be of any help.

Regards,

Dave




---------------------------------------------------------------------
Computers, you can't live with them and you can't live without them.
---------------------------------------------------------------------
"Dilbert" <HaveNoSpamMail (AT) memail (DOT) com> wrote in message
news:P22tb.90$FC6.70 (AT) newsfep4-winn (DOT) server.ntli.net...

Hi there, im using 2 classes for my program. base and gui.

in base, i have set: int size = 5;

and in gui, with the use of a comboBox, i have:

if (jComboBox.getSelectedIndex()==2 ) {

base.size = 8;

}

this compiles fine,and also runs fine.



The int size ... in my base class effects the way the program runs, and

must

have a start value.

The idea is, the user selects index2 of the comboBox and it changes the

int

size value from 5 - 8. If i use the comboBox at index2, no errors turn up,
yet it just doenst work.

Ive tried repaint(); but this didnt work either, anyone got any ideas?

Cheers








Back to top
Dilbert
Guest





PostPosted: Mon Nov 17, 2003 8:57 pm    Post subject: Re: changing an int value across classes,kind of working :s Reply with quote


"kevinc" <kevinc (AT) elp (DOT) rr.com> wrote

Quote:
Things that I would look at.

1) How are you checking the value of base after the GUI code has changed
the base.

2) Are you sure that the base instance that your GUI is changing is the
same base instance that you are inspecting after the GUI makes the change.

3) As an aside. NEVER,NEVER,NEVER have a class that publicy exposes it's
instance vars. use acessor/modifier method instead. This way. You
would be able to tell if a change was made to base.size, by using
base.setSize(int someVal){
System.out.println("Im changing my size to " + someVal);
}

Dave wrote:
Have you checked in the debugger if the value of your class attribute
'size'
is changed to 8 when it should? If this goes allright, the problem must
be
somewhere else but I have insufficient information about what should
happen
when it gets assigned value 8 to be of any help.

Regards,

Dave




---------------------------------------------------------------------
Computers, you can't live with them and you can't live without them.
---------------------------------------------------------------------
"Dilbert" <HaveNoSpamMail (AT) memail (DOT) com> wrote in message
news:P22tb.90$FC6.70 (AT) newsfep4-winn (DOT) server.ntli.net...

Hi there, im using 2 classes for my program. base and gui.

in base, i have set: int size = 5;

and in gui, with the use of a comboBox, i have:

if (jComboBox.getSelectedIndex()==2 ) {

base.size = 8;

}

this compiles fine,and also runs fine.



The int size ... in my base class effects the way the program runs, and

must

have a start value.

The idea is, the user selects index2 of the comboBox and it changes the

int

size value from 5 - 8. If i use the comboBox at index2, no errors turn
up,
yet it just doenst work.

Ive tried repaint(); but this didnt work either, anyone got any ideas?

Cheers









Thanks for both replies dave and kevin c.
In more detail, i know that it works, because once i choose a value from the
combo box, and it changes base.size to say 10, nothing happens, but when i
reload the applet, via the actual applet program, it changes :S

ive tried validate()
repaint()
adding and removing forms

kevinc, in more detail what you were on about, ive been looking at that kind
of idea, just not sure how to go about it via 2 classes (base containing all
the hard numerical and detailed code, and gui, the front(used for changing
the values)

Thanks though for any ideas, im sure ill get there sometime :P



Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.