• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could need some help with a variable problem  RSS feed

 
Peter Müller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I am currently working on a small java programm. I use netbeans for it. And obviously I am new to java.

Basically its a calculator that change the input value into another value: like 10 € into whatever $ and same with Inch and Centimeters.

Therefore I need a second jDialog Form where i can change the factors for the calculator and start the calculator again.

Here is my problem: I can open the second Dialog but if I want to change the factor it doesn`t change the value in the variable and the second calculator frame is with the old factors.
It seems the double variable isn`t working globally


I will add the files later when i find out how, I am currently in a rush.

Every form of advice is gladly taken

Greets
 
Jacob Anawalt
Ranch Hand
Posts: 64
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have a second dialog to change the units?

Is the use of a second dialog your own choice or a design constraint imposed on you? I only ask because it seems easier to just have a combo boxes to switch units.

Lets say you have to have the second dialog. Does it pop up and you change your units and click OK then it disappears (modal) or is it possibly always visible to change at any time, like in another panel or floating window (modeless)?

If I had a modal dialog with a couple of members to track the unit selections, I would just query their values after the dialog closed and reset the calculator and update it's units.

If I had to work with a modeless dialog or a second panel, I would setup event listeners so that the calculator was reset and it's units updated every time the units were changed in the other panel.

Have you looked at the Event Listener Tutorial?
 
Peter Müller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have a second dialog to change the units?
Is the use of a second dialog your own choice or a design constraint imposed on you? I only ask because it seems easier to just have a combo boxes to switch units.

I have to do it.

Lets say you have to have the second dialog. Does it pop up and you change your units and click OK then it disappears (modal) or is it possibly always visible to change at any time, like in another panel or floating window (modeless)?

Yes, it is modal (it has to be).

If I had a modal dialog with a couple of members to track the unit selections, I would just query their values after the dialog closed and reset the calculator and update it's units.


After several tries and help of an other student it works now!
I used something like this:



public DialogSetup(FrmUmrechner parent, boolean modal) {
super(parent, modal);
this.faktoren = parent;
faktor1 = FrmUmrechner.faktor1;
faktor2 = FrmUmrechner.faktor2;
initComponents();
}


Thank you very much for your help.


Have you looked at the Event Listener Tutorial?

I'll do this now
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Müller wrote:I have to do it.

Then next time, please explain that; we have no way of knowing.

After several tries and help of an other student it works now!

Great! Well done.

However, I have three questions:
1. Would you have come up with this solution on your own?
2. Do you understand how (and, probably more importantly, why) it works?
3. (possibly most important) Would you recognise the same problem in a different scenario?

I understand that "getting the program written" was probably the most important thing for you, but oddly enough, it isn't. The object of most courses is to get you to learn; and if you simply took a solution handed to you by someone else (even with the best intentions) without understanding its mechanics, you may very well run into the same problem again, in a slightly different guise, and not even recognise it.

Take it from an old programming soldier - understanding is much more important than "getting the right result" - and I've usually learned a lot more from my failures than my successes.

HIH

Winston
 
Peter Müller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then next time, please explain that; we have no way of knowing.

I promise I'll do

However, I have three questions:
1. Would you have come up with this solution on your own?

Honestly, I don't kow. Probably not in time.


2. Do you understand how (and, probably more importantly, why) it works?

Yes, it's actually easier than I thought.

3. (possibly most important) Would you recognise the same problem in a different scenario?

Yes, I think so but only time will tell.


I understand that "getting the program written" was probably the most important thing for you, but oddly enough, it isn't. The object of most courses is to get you to learn; and if you simply took a solution handed to you by someone else (even with the best intentions) without understanding its mechanics, you may very well run into the same problem again, in a slightly different guise, and not even recognise it.


I heard that a lot already in my early progammer-days
I'm normally a person who wants to learn how to do something on my own. But this test was a bit differenet. We have 2 weeks for every little program we need to code this semester and in this weeks we have class that should teach how to do these tests. However 3/4 classes got canceled and it seemed very difficult at first (especially for newbies).
"What we learned so far" it was nearly impossible to do it like the professor wants it.

Anyway I will keep your advice in mind.

Thanks for your response


EDIT: "help of another student" doesn't mean he did everything ;)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!