Jacob Anawalt

Ranch Hand
+ Follow
since Oct 27, 2010
Jacob likes ...
Netbeans IDE Linux Windows
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jacob Anawalt

Nice job keeping after it and solving the visible concerns.

Are you going to continue with solving the design issues? Would you like help understanding how you could do this without creating a table column that you have to set to invisible?
9 years ago
Is it a requirement that the RGBColor array of arrays held by RGBImage has to change shape, or can RGBImage know it is rotated 90 degrees and print accordingly?
9 years ago
I like to think of creating objects and see the main method as a way of testing or interacting with them. Here is an example creating an instance of a class and calling it's methods like Fred said:

See how the main method driver gives an example of how one might use MyClass as part of a larger program?
9 years ago
I was envisioning those three lines being in your FileModel class or wherever you are calling static String[] testContent(PDFDocument pdf) and holding this.data and not at the end of PDFCheck.testContent(PDFDocument pdf) (that would be infinitely recursive with no base case.)

Before trying to apply my last suggested changes your program seemed to be meeting it's requirements. Celebrate that and make sure you save a working copy of the code at that point (using some kind of version control system would be great.)

There are design issues, what you may see referred to as "code smell", remaining. If you want to continue to improve your skill at the art of coding well the next step is to identify these issues and refactor. To keep the desired functionality while fixing these design issues. The most glaring one to me is the use of these static class variables which are a Java way of having global variables. It may take stepping back and looking at your overall design and some learning about better designs.

If you aren't convinced, perhaps ask others or search around about global or static class variables to see where they have tripped others up. Add "considered bad" or "considered harmful" or "thread safety" to your search terms.

If you are, then take a look at one or two of your static class variables like PDFCheck.errorMessage and PDFCheck.contentError and think about how all of your code would need to change if they weren't static. Remove the static keyword and look at all the errors. What are the problems? What are ways to accomplish the same user functionality without using static fields (variables)?

It may not be easy yet, but once you learn to think about the problem differently it can be.
9 years ago
Where is GrossPayService defined? It sounds like it has a constructor that takes a string and two doubles. Let's see it.
9 years ago
That's a lot of work when just the character to the left of i and to the right of 1 would do.

If I do need an Integer, I prefer valueOf over new Integer. Plus it works out toString by itself in this context (JLS 5.18.1 & 5.1.11).
9 years ago
It's hard for me as well, looking at the code with blinders on, guessing what is on either side of the snippets.

I'm working off the expectation that the most recently revealed snippet, where you add the row of PDFDocument info to data (PDFCheck.data?) looks something like this, merging what you have revealed to my pseudo code:

See how errorMessageArrayList error messages would be in parallel to data? So the index of the one (the same as the index to your JTable row, unless you're sorting or filtering - if so, adjust accordingly) is the same as the index to the other?

It looks like in your latest example you stuck all the error messages into the content error column and then you pull them out from the JTable to create a JTextArea with just that row's error messages. Is that working for you?
9 years ago
You are seeing the difference of adding an integer with a space character (' ') and concatenating with a single space string (" ")
9 years ago
I've been using JDK 6, 7, and 8 on Windows 8 and 8.1 systems, no problems, just to put that thought to rest.

Maybe this is the key "altered the JAVA_HOME in environment variables". Link #4 that Campbell shared talks about a bad path causing the problem.

Do you have jil.dll in your JDK\bin directory? If you do, check your %PATH% and %JAVA_HOME% again.
9 years ago
Indexing typos aside, you seem to know how to print out the names of your appetizer menu by index (line 50-54). Isn't that what you want to do after they make a selection?

When the user enters 3, what do you do with it?
9 years ago
What trouble are you having in deciding how to change your GrossPayService constructor declaration(s) or the arguments to the constructor on line 21 to fix this error?

As an aside, an addEmployee that takes arguments of the employee to add makes sense, but seeing it read one or more employees from a file doesn't. I would do that in a readEmployees(String fileName) or some such thing.
9 years ago
It still looks like you're using global variables, that testContent is not returning values, and I don't know how you are holding and retrieving the correct row from the list of error messages.

I was thinking of something more like this quick & dirty pseudo code example:

See what I mean about a second container to store the error messages, and how I pull back out just that PDF's error message for the Error Report dialog?
9 years ago

When I first started reading your post I thought the Factory would create some kind of JComponent that would be a form field and label, so when I got to public void getFormField () I was confused by it returning void. (When I see getSomething, I expect it to return Something.)

Then I read the getFormField implementation in Name and saw it was using a Scanner on System.in, I did a double take because I thought this was suppose to be a graphical and not a command line interface program.

FormFactory's getForm is a factory pattern, but I wonder if you meant to use equalsIgnoreCase based on the way you call it in FormFactoryDemo.java.

Does the program work the way you expect it to? Does it work the way your instructor expects it to? If so, I'll need to reset my expectations of using a factory pattern to create input forms that consist of a text label and an input field. If not, you may not be on the right path yet.

9 years ago
I can't comment on the rest of the code since it is incomplete but public static int printArray says it will return an int but it doesn't have any return statements.
9 years ago
One way to work around the long string issue would be to setCellRenderer with a custom renderer you extended from DefaultTableCellRenderer that would just print the first N characters, something like "My really long error messages" turns into "My really long..." via the renderer.

If you don't want that kind of text there, then keep putting contentError in and store the error message strings in a different container that you pull the values back out of.
9 years ago