Win a copy of Spring Boot in Practice this week in the Spring forum!

Michael Von Thorn

Greenhorn
+ Follow
since Oct 07, 2016
I am a new programmer and I am learning Java.
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Von Thorn



Simple question - does it ever fail? If so, how should the exception be handled to ensure that the program still runs?
I have been using textFieldFocusLost() to update the sliders.
But, I would prefer to have the sliders update themselves as keys are entered.
The KeyTypedEvent did not work. It was always one keystroke behind (e.g. a textfield entry of 100 would only reflect 10 on the slider).
5 years ago
I made it using NetBeans. I am confused about how to do it.
5 years ago
Hi guys,

I made a program that allows the user to select a shape.
Given the selected shape, properties appear (e.g. radius for a circle, length and width for a rectangle, etc.).
The program then displays calculations such as area, volume, perimeter, etc.

My problem is that I used four JLabels/corresponding JTextFields, and I simply hide some of them, depending upon the selected shape.
I change the label display when a new shape is selected, and it works, but it also looks stupid, because there is extra space on the bottom for those shapes that require less fields.
The attached picture demonstrates how silly circle looks with all of that empty space.

Is there a way for me to either keep the JTextField dimensions intact regardless of whether they are visible? (It is the collapsing of them that causes the problem).
Even better, is there a way for me to actually control the amount of empty space on the bottom?
I need to hand this in as homework tomorrow and I want it to look okay.










Thank you,
Rob
5 years ago
Wow. Thank you! I got it working and everything just clicked for me. I can't believe that I was leaving out the most critical part; though I agree that it seems to be an odd manner of performing the calculation.
(Perhaps our instructor would prefer it if our calculations were placed within the main method, simply enough. He was really only specific about using private data fields and then making use of getters/setters).
In any case, you have helped me to reach a greater level of understanding. I am truly grateful.
5 years ago
Thank you. I get what you are saying. I tried to use an array.
I created an array containing the two points and attempting it that way.
I still received the cannot find symbol message.
Will that never work? Is the array of those two objects (point1 and point2) not an object itself?
5 years ago
I figured out that my getter and setter were improper. That much has been fixed.
But I am still 100% confused as to why I cannot use my diagonalLength method.
I am trying to use an object array now:


5 years ago
Actually, my data fields are all supposed to be private. I meant to change that back. I was testing whether it made a difference and it did not.
5 years ago
We're learning about multiple classes and objects right now.
We are seeing how private variables can only be accessed within their own classes, etc.
Can someone tell me why my diagonal method won't work when I try to print it? It says "cannot find symbol."
My getter methods do not work, either. It seems that no methods from my Point class can be found within my main class...

5 years ago
I meant to respond to the pie question, too. I do know that it is "pi."
For whatever reason, the professor wanted us to refer to the variable as pie within the program (perhaps for fun).
I'm taking calculus II right now and I'm really good at math. I swear.
5 years ago

Campbell Ritchie wrote:MVT: welcome to the Ranch

I am afraid I shall have to ask you to edit one post to remove the CAPITAL LETTERS. As you doubtless know, writing all upper‑case is frowned upon on all websites.
Please spell the variable pi not pie, unless you usually write pie for π. What Henry meant is writing == true or == false is very error‑prone, as you can read in this thread.



I'm sorry about the caps, Campbell. I was very excited at the time, but I do promise not to do that again.
Thank you to everyone here for accepting me right into the community. I am having a lot of fun programming and I look forward to reading more posts.
As for this thread question, I just want everyone to know that I solved the problem.

The working code segment is below:

5 years ago
My big problem is that a logic flowchart doesn't indicate whether you need an if, a while, a do while, etc...

The middle part which looks like -
(isRangeFound = "false")
and (pie >= 3.14159265)
and (pie < 3.14159266)

doesn't help me. I don't know if that parenthesis is showing me that I need a while loop or if it's just reminding me that isRangeFound is false before this part.
5 years ago

Henry Wong wrote:
Hint: Be careful to not confuse the assignment operator with the equality comparison operator. See your while loop.



Thanks. Nice spot!
I change it. I still can't get it right, however.
I'm going crazy right now. I had an easy time with the other assignments, but this is killing me.
5 years ago

Emil Jennings wrote:

...it gives me the very last value of pie within that range (at the very last iteration - 1000)



Yes, it does because you never ask isRangeFound.

See?



Do you mean like this (below)? It still gives me a final line output of: The number of iterations to get to 3.14159265 is 1000. π = 3.1415926533





Also, since it's an intro class, he attached a logic flowchart (and that's what I've been trying to follow).
I'll include the attachment.
5 years ago