Beth Laguardia

Ranch Hand
+ Follow
since Jun 01, 2008
Merit badge: grant badges
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Beth Laguardia

Originally posted by Brian Cole:


I haven't actually run your code, but I would guess that it's the
normal limitations of the double type that java (and many
other languages) uses. There are some values that it just can't
represent, and 123456789111 is one of them. If you don't like
this, you could try using BigDecimal instead.

While I'm here, allow me ask a couple things about your code:

1) Why bother to use String variables b0, b1, etc? (I would just use
the String literals "0", "1", etc. but if you really want to use those
variables, perhaps you should declare them to be static final.)

2) Is there a reason you're doing setLayout(null) and manually
calling setBounds() on everything?




Thank you for explanation. I do not know yet how use BigDecimal but will check on it.

With using the string literals, I will denitely change it string literals. Thanks for that input.

I have no idea yet what is static final, but i have check on it also.

I have set the frame to null because if i remove if all my buttons will be gone. Is there a better way to do this?

Thank you all or the response.. )
16 years ago
Hi everyone, I am trying to make a simple calculator.. everything works but when i tried to input more than 11 numbers in my textfield then press the operators the numbers in the ext field CHAnGES!! I have no idea why!

Can please anybody healp me? Thanks

Sample input: 123456789111 Then if I press one of the operators it will change to 2147483647..



[ September 19, 2008: Message edited by: Rob Prime ]
16 years ago
Oh my! I am fairly new in java so I some of this i have not tackle yet but thanks to the reply..

I guess i will just stop beig mbitious and do not go to graphics yet.. hehe

But thank you all!
16 years ago
Thank you all for the reply. I am not familiar yet with swing worker..
But will check it and try to understand..

The loop works when its inside the go() method. Ii was able to bounce the ball. But when i try to put it to the other class, its not working anymore..

Is there any alternative aside from swing worker?

Thank you all for the quick response.. I really appreaciate it..
16 years ago
This program is not doing what its supposed to do:



What i was hoping is that if i click the bounce button, the ball will move up and down.. but it's not doing it..

Anybody can please explain what's wrong with the program?
16 years ago
Your right!

I change this

to ths:

Thank you!
16 years ago
Brian: Yeah, sorry. The first program that I posted is a working program.

Here's the not working program.. sorry for the inconvenience..



Please somebody explain what's wrong? Thank you all..

[ August 28, 2008: Message edited by: Beth Laguardia ]
[ August 28, 2008: Message edited by: Beth Laguardia ]
16 years ago
I am new to Swing and I wonder if somebody can explain to me what is wrong with the program I am making:

Here's the code:



Here's the error:


Please explain to me what's wrong.. ANybody? Thank you..
16 years ago

Originally posted by Mark Vedder:
OK - I see the problem:


The drawing panel is getting added on top of the button and is therefore covering it up. If you look at the frame when it runs, you will see a small black stripe at the bottom. That's the MyDrawPanel. Change the code so the panel is added to the CENTER:


Was that just a typo on your part (which we've all done) or is it wrong in the book?




Hey Sir Mark,

It was a wrong typo on my part. I am so sorry , I am embarrased, I am using two books so I mixed it up. But I understand now what is serialization. My proffessor have not teach us that, but we will have GUI the next meeting. Just trying to advance study..

Thanks for the help.
16 years ago


Here's the code from Head First Java, but it is not working on my Eclipse.
The output is wrong but there was no error only a warning in the code itself that says : The serialized class MyDrawPanel does not declare static final SerialVersionUID field type of long

I do not what does it mean!

Please help.
16 years ago
I understand now. Thanks for the reply.
16 years ago
I purchased the Head First Java And i am into the array list topic already. There's an example named class DotCom where the author used private ArrayList<String> locationCells.

I tried the program but it came up with an error. Please tell me what i generated the ff error: setLocations(java.util.ArrayList<java.lang.Integer> i DotCome cannot be applied to (int [] )
newGame.setLocations(locations);

Here's the code:







I really think that the error is code int [] locations = { randomNum, randomNum + 1, randomNum + 2 }; because it's an integer and the arguments at the array list is a String.

Please help. Thanks!
16 years ago
Thank you very much.

I understand it now better than before.
16 years ago
Thank you for all response. I appreciate it greatly.

Originally posted by Ernest Friedman-Hill:


Now, as to your question: you should be able to remove the getRadius() method entirely without having any effect on this program, since no code here calls that method. It doesn't matter what a method does if it never gets called! Yeah, I was able to remove it now without a problem unlike yesterday. It's an error on my part. Sorry po.



The getRadius() method asks for the value stored in the radius divider. It could be used like

double radius = aCircle.getRadius();

Is this helping at all?



Yes sir, i am beginning to understand a bit. I read the following from an ebook which i do not undersand though.

[Accessor (or observer) methods read property (ie. field variable) values and are conventionally named getFoobar() or whatever the property is called.

Mutator (or transformer) methods set property values and are often named setFoobar() etc. Mutators can be used to ensure that the property's value is valid in both range and type.

from that ebook it asked me to create a program with setRadius, getRadius, and calcDiameter. Why do i need to use getRadius when In my program I can get the diameter without using the getRadius.

Or I should create a program with getRadius on it? But how? Can you please help me sir? What's the importance of it?
[ June 28, 2008: Message edited by: Beth Laguardia ]
16 years ago
Hello everyone,

I would like to understand how set and get works in the following program.

I do not understand why deleting the getRadius method creates an error. If i looked at it it seems that getRadius method does nothing but I know it does something that i cannot understand.

Can somebody explain to me how the following program works please?

16 years ago