Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FearIt
Mar 11, 2007
How do I pass objects to a method in another class so that when I manipulate the values in the method the original object isn't modified?

My example code would be far too long to post but it's basically something like:

ObjectA A = new ObjectA(blah, blah blah);
ObjectB B = new ObjectB();
int crazyCalculations = B.doSomeCalculationsWithA(A);

Is there a quick way to make it so the original A won't be changed by B's method?
Hopefully some sort of way that won't make me rewrite all my methods completely but simply just kinda add a keyword or something..

Adbot
ADBOT LOVES YOU

FearIt
Mar 11, 2007
I'm typing 'objectsName.' in my IDE (eclipse) and when the list of methods comes up none of them are clone(). The object is a class I defined myself, would I need it to implement something for .clone() to work? Or alter my class in someway?

FearIt
Mar 11, 2007
I like this constructor idea, it seems to be the neatest codewise and would require the least amount of revision of my broken code. In the constructor how would I go about creating a copy if everything is passed by reference still? Is it more complicated if my class serves as a ArrayList container for sub classes?

FearIt
Mar 11, 2007
Hello CoC, I was wondering how to run a desktop swing application without having the ugly console window staying in the background.

I'm currently using a batch script which simply calls "java myMainClass" and the console window seems to just get stuck there until my GUI is closed.

Is there a better way to do this?

Edit: I'm using Windows if that makes a difference.
I've also tried making a c++ executable which tries to start my java program through WinExec() but the problem still arises.

FearIt fucked around with this message at 02:53 on May 14, 2009

FearIt
Mar 11, 2007

OddObserver posted:

javaw myMainClass if my memory serves me right.

Jackpot, thank you OddObs

Adbot
ADBOT LOVES YOU

FearIt
Mar 11, 2007
Hello again CoC,

I'm trying to add a right click JPopupMenu to a JTextArea so that I may easily copy, cut and paste.

I've tried googling for examples but I haven't found any good ones that really fit what I'm trying to do.

Any help would be great. Thanks CoC.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply