This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jacob Morehouse

Greenhorn
+ Follow
since Feb 22, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jacob Morehouse

Got it, thanks Ulf Dittmer!

9 years ago
Hi again,


OK, I'm stumped. When I System.out.println() the text looks great and the newline/line breaks appear normally. But when I save the string to a file they all appear on one line.

The newline characters just disappear. I've tried with no charset (letting in default), UTF-8, and US-ASCII. None of those made a noticeable difference. What am I doing wrong here?

Thanks,
Jake
9 years ago
Of course after giving up and posting, I solve it:


And away we go! Still getting used to generics. Also, welcoming any better or more concise solutions. There's always someone out there with a better way to skin the proverbial cat.

Thanks,
Jake
9 years ago
Hello!


This is probably an easy one, but for some reason my searches turn up nothing. I'm possibly Googling this wrong? Anywho, here's my code:


This results in references to those objects, like "passwordgeneratorfx.Password@41b192cc." I've given the Password class a method of "getPaswordContents" that returns a string value, but I cannot seem to reference it here. How would I call that method here on each object in the list?

Thanks,
Jake
9 years ago
Thank you John! I tried it so many different ways and never thought to change the file type. I tested with a .png and of course it worked perfectly.

Thank you so much for the detailed and thorough reply, very appreciated.


Jake

9 years ago
Hello!


I'm a bit new to Java and JavaFX, so I'm sure this is an easy fix. First the context - I've written a program to list TIFF files and make them viewable in a little popup window. Here is the code for that window:


When the new stage appears it is completely empty. I've spent a bit of time on this and I think my problem lies in one of two places: I have specified the file path incorrectly (though this is the only variation that doesn't throw an exception), OR I have incorrectly formed the UI components and something isn't attaching to the scene/stage.

Even if someone can tell me definitively which of the two it is it would be a great help, then I'm only diving down one rabbit hole...

Thanks!
Jake
9 years ago
Hi Ritesh,

You have a couple things going on, I'll try to walk you through. First, spacing is goofy... makes it hard to for you to debug (using NetBeans, alt+shift+f will fix spacing).

This can't exist here, can't instantiate an object of the class from within the class:


You have to put that code in the main, like this:



Hope that helps,

Jake
9 years ago
Hi ven,


Great question! A constructor is not really in use until it is called to construct an object, in which case the "this" keyword would point to that object. For example you might make a method in a class that absorbs input from an XML file, but just because that XML data doesn't exist at compile time doesn't mean there is a problem. The constructer only "constructs" when an object is instantiated: myObject something = new MyObject();

Home that helps.

Jake
9 years ago

Darryl Burke wrote:

Jacob Morehouse wrote:Got it. In case anyone else Googles it and finds this post. It had nothing to do with generics, everything to do with objects/classes.


If you Googled and got here, hopefully you'll read the entire thread and follow any links to learning resources, from which you will conclude that this has everything to do with Generics.


You found your post not to be vague? I understand how your feelings might be a little bruised here, but a post like your first one holds very little value not because you were incorrect, but because you made no effort to support your claim. I realize your attempt was to get me to look up generics, but a comment like yours on the Internet just gets immediately ignored as another troll. A comment like K. Tsnag's gets me looking up generics.
9 years ago

K. Tsang wrote:Hi Jacob

In fact changing your code to use array is one solution, but using generics can surely make life easier for large collections.



Thank you for posting - I would consider your solution superior as well, you don't have to define the exact length of the array which is also good.

To verify I understand, <People> is casting the "type" of the array to "People"?

Jake
9 years ago
Got it. In case anyone else Googles it and finds this post. It had nothing to do with generics, everything to do with objects/classes. I changed my main:

If you Googled and got here, hopefully you didn't waste time on generics on your way to my answer.


Jake
9 years ago
Thanks Bear, moving in the right direction now.
9 years ago
Hi Darryl,


I'll take from your vague post that this forum isn't friendly to entry level questions. Is there another forum (or site entirely) you would recommend I post this question? I feel like we're already off to a trolled start and neither of us is adding value to this forum at this point.


Thanks
9 years ago
Hello!


I've done this before, I cannot figure out what I am missing. In short, I can access an objects methods (like gets and sets) while it is just an object, but when I put it into a structure like an ArrayList I cannot access those methods.

The class:


Now the main:


It has been awhile since I've done anything with Java, what am I doing wrong here? I'm sure it is something simple but I'm about 6 hours in and still no solution. Any help would be appreciated.

Thanks!
Jake
9 years ago
Thank you Janeice, that did the trick. You are correct. It didn't immediately click what that meant, but as I looked it over it makes sense. In case anyone else get's stuck, the corrected version of my code is below.


Daragaaz



10 years ago