Results 1 to 7 of 7
- 10-22-2010, 08:24 PM #1
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
The field "name" doesnt apparently exsist :/
This code:
PHP Code:try { f.getClass().getField(txt).set(txt,real.substring(0,i)); } catch (Exception e) { e.printStackTrace(); }
PHP Code:Can not set java.lang.String field Window.name to java.lang.String
Why cant it assign a string, to a string object?
- 10-22-2010, 08:37 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 785
- Rep Power
- 12
Because you dont read the API Doc *g*
--> Field.set
Parameters:
obj - the object whose field should be modified
value - the new value for the field of obj being modified
try: set(f,real.substring(0,i));
- 10-22-2010, 08:40 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 10-22-2010, 11:34 PM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
Ahhh okeee!!! :D
I did read it, tho I didnt understand what they ment with object
so I thought they ment object type like String and int etc :P
Well, now I sorta fixed it, the window I belive, is a copy of the real..
Because the window name doesnt change in any of the open windows, only in the one called this.f
Heres a lil bit of my code:
Java Code:public class AnimationManager { public static void text(Window f, String txt,String real,int time){ new Thread(new writeString(f).start(); } } class writeString implements Runnable{ Window f; public writeString(Window f){ this.f = f; } private static void wait(int time){ try{ Thread.sleep(time); } catch(Exception e){} } @Override public void run(){ changing f here wouldnt change the f that we got in the text method right? If so, how can I change the text methods f from this method? } }
-
Myself, I still am finding it hard to see what you're trying to do, but I also agree with the others that reflection doesn't smell right here. Consider creating and posting a small runnable version of your problem, an SSCCE.
- 10-22-2010, 11:53 PM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
Well, my main idea is to have a method
that I can call that would run in an extra thread, thus not
hogging up the maincore.
What I want it to do is to change values in a class instance called
Window.
Window "f" have the parameter-String "name"
So I want to call a method text(f.name,"awsome",4000);
Using that simple method, it would add a character, one at a time
until f.name = "awsome"
This should also only take 4000 miliseconds.
That's what I want to do, and probebly I overcomplecated things eyy? :P
- 10-23-2010, 12:15 AM #7
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
Similar Threads
-
connection = DriverManager.getConnection(DATABASE_URL,'"+userid +"','"+password+"');
By renu in forum New To JavaReplies: 3Last Post: 10-12-2010, 05:21 PM -
How to change my form design from "metal" to "nimbus" in Netbeans 6.7.1?
By mlibot in forum New To JavaReplies: 1Last Post: 01-21-2010, 10:20 AM -
"package javax.microedition.lcdui doesnt exsist" But on suns webbpage they say it do!
By Addez in forum New To JavaReplies: 4Last Post: 10-30-2009, 08:54 PM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 07:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 08:35 AM
Bookmarks