Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

W Pearce

Ranch Hand
+ Follow
since Jan 06, 2009
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 W Pearce

The big concept behind it is that you don't want your member variables being able to be manipulated outside of their own class. For example, if you have an int called height in a Bacon class, you don't want any code to be able to make an instance of that class and set height directly:



Instead, you want to have your instance variables wrapped in getter and setter methods, so you can perform validation on them when something is passing them a variable. So for the example above, we would do something like:

And these would be called from your code like this:
10 years ago
You're going to hate to hear this, but it really depends. If you use OpenGL bindings for Java, you can get some pretty great performance out of it. How intensive are you talking? 2D animation can be accomplished in either fairly simply and without a lot of graphics power. 3D might be a different story.
10 years ago
Wow. I can't believe I overlooked something like this. Every time I split the string on an apostrophe, it cuts that character out, therefore when a field had a description with a possessive noun it was removing those characters. I have it replacing the characters with a space now and we're back up and running. I feel like such a schmuck!
I am creating a program that first reads each line of a fixed-length field document. Each line is a record, and depending on which character you are at, the values mean different things (for example, characters 1 through 20 may be an identification number). I am running into a problem when I load these through the JDBCODBC driver into SQL Server where it is dropping the white spaces. This means that when I am parsing the data, if a field has 3 characters instead of the 4 designated to it, all the fields following that will be off by one characters.

For example:
222 333 444 would be parsed as 222, 333, 444 (fields separated by commas)
but
22 333 444 would be parsed as 22, 334, 44

Is there a way I can force white space to stay?
I'm able to create a simple jump in a side scroller (rise and fall at the same rate), but I'm for some reason unable to get a nice "rise at a slower and slower rate, peak, fall at a faster and faster rate" smooth arc. Does anyone have any ideas that might point me in the right direction? So far I have this, which rises at a slower(ish) rate over time, peaks smoothly, but then falls at a pretty slow rate. When a jump is performed by pressing a key, yVel is set to -10 and increases until it reaches just under 10 which does cause the object to rise then fall, just not how I'm looking for.




EDIT: Jeez, I hate it when a solution is so simple it's the last thing you think of. I've got it working now, but if anyone wants to contribute your own ideas of one, feel free to go ahead.
10 years ago
ha yea sorry, apparently skimming isnt as effective as reading
11 years ago
another solution might be to call the revalidate() method
11 years ago
using the method I suggested above (and a little free time i had this afternoon) i came up with this as a MouseListener



when i added that to my ArrayList<JTextField> it worked well.
11 years ago
try changing LG.button4.setText(LD.getMaxID().toString()); to LG.button4.setText(LD.toString());
11 years ago
I would suggest experimenting with an ArrayList<JTextField>. Add a listener to your first one and in the actionPerformed method add a new JTextField to the ArrayList as well as set up it's listener and add it to the panel. Just a thought, I haven't really ever tried to do something like this.
11 years ago
I think it's because you're re-decarling your instance variable array for your buttons in your constructor. Try changing
to
11 years ago

Akanksha Joy wrote:You mean to say that it matters where we place the square brackets?


Yes, for example in your first code snippet, putting [] before variable names makes them all arrays. But if you had something like thisonly j and l are made into arrays, while k is a normal int type. I would highly recommend following Fred's suggestion and putting these on separate lines.for readability's sake and to cause less confusion.
11 years ago
both are arrays

Edit: In your FIRST example, both are arrays. Hope that wasn't confusing.
11 years ago
Excellent point Joanne, the Java 6 SE documentation lists Double's signature as 'public final class Double' so yeah no subclassing. Thanks for bringing that to my attention, I'll have to remember to check that next time.
11 years ago