Jonathas Carrijo

Greenhorn
+ Follow
since Jul 25, 2002
Merit badge: grant badges
For More
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 Jonathas Carrijo

Simon's Java 2 Cert Study Guide says the following:

The circumstances that can prevent execution of the code in a finally block are:

  • An exception arising in the finally block itself
  • The death of the thread
  • The use of System.exit()
  • Turning off the power to the CPU
  • I love you! You saved my life... my future!!
    Thank u so much
    Juba d-_-b
    21 years ago
    I'm trying to load an image and show it in a Canvas. I used the default toolkit's getImage() to load it, used a MediaTracker to, of course, track it, and it showed me that I got an error loading the image... Why?? Please... I need it working tomorrow. Look at the (sample) code:

    Debug 1 prints out:
    File exists: true
    Debug 2 doesn't print
    Debug 3 prinst out:
    Error loading: true
    Debug 4 prints:
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    and so on...
    Anybody can tell me what could be wrong since I get an error loading the image, and the image is actually at c:\juba\used.bmp... (debug one shows that)
    Thanx in advance
    Juba d-_-b
    21 years ago
    Please guys... I really need help on this!
    Haven't anybody ever had a happy experience loading images?? Please share with me
    Thanks a lot
    21 years ago
    I added this to my code. Everything compiled and ran fine, but still didn't show my image...


    I got as output:
    Error loading: true
    which means that there was an error loading the image... I tried to use the getImage() method which takes an URL as parameter, like this:

    instead of the tk.getImage("c:\\juba\\used.bmp");
    Didn`t work yet... I think I'm gonna migrate to Swing... or even to C# (hehehe)
    Am I attacking it the right way? I mean, is the problem actually in the path specification?
    Anybody help, I need it deployed till tomorrow...
    Thanks much!
    Juba d-_-b
    [ November 21, 2002: Message edited by: Jonathas Carrijo ]
    21 years ago
    I changed the paint() method as follows:

    And all I got is hundreds of thousands of:
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    drawImage: false
    Why??? What can be done? I really need this working! Please help me...
    Thanks,
    Juba d-_-b
    21 years ago
    I have to show a bmp image in a Canvas, inside a frame. I tried to use Toolkit's getImage(String <filename> , but it didn't work... Actually I copied the code from an old post here at this forum. Here it is:

    It compiles and run fine, but the image simply is not painted, and it actually exists (i get a true printed in the console). Why doesn't it work? How can it be done (without using an applet) ?
    Thanks in advance...
    JUBA d-_-b
    21 years ago
    When I compile the code:

    I get the following compiler-error msg:
    "Can't specify array dimension in a type expression."
    Why's that? According to Simon's Cert Guide, "Since array size is not used until runtime, it is legal to specify size with a variable rather than a literal".
    Thanks,
    Juba d-_-b
    [ November 06, 2002: Message edited by: Jonathas Carrijo ]
    Thanks a lot... think I gotta redesign everything, and so even my understanding of stuff
    Jonathas d-_-b
    21 years ago


    1. static variables initialization
    2. static initializer block execution
    3. constructor header (super or this)
    4. instance variable initialization
    5. rest of the code in the constructor


    In Code1, value = 100; is #5 (rest of the code in the constructor), and happens after instance variable initialization (#4).
    In Code2, value = 100; is #2 (static initializer block execution), I guess, and at that time instance variables have not yet been initialized...
    But, I just noticed now, at the end of my post , the initializer has no static modifier... is it a requirement for it to be static to have its execution time at, say, #2?
    If it is, so when will the non-static initializer be executed?
    Thanx,
    Jonathas d-_-b

    Originally posted by peter greaves:

    int k=6;
    k = k++;
    System.out.println(k);
    prints
    6


    Hi,
    k++ returns the current value of k and then increments it.
    ++k increments k and then returns the incremented value.
    When u write k = k++; things happen in the following sequence:
    1 - the current value of k is returned (6).
    2 - k is incremented, and its value becomes 7.
    3 - the assignment is executed, and the value returned by the expression (6) becomes k's value.
    Thus, when u print out the value of k, you get a 6, not a 7!!
    Regards,
    Jonathas d-_-b
    Hi,
    I have no experience with networking in Java, so I think mine is a newby question.
    This is my situation. I'm writing a ping-pong game (applet) just for practice and learning. And the intention is for two people to compete each one from his computer. The Stream class constructor requires a server name and a port. Since I'd like to connect any two machines to get playing, I do not want to specify the server name at coding-time... How do I handle this?
    Thanks a lot,
    Jonathas d-_-b
    21 years ago
    Hi,
    I think there's a rule of thumb that could help here. Whenever a string can be doubtlessly evaluated at compile-time, it will be! That requires you NOT to use any object reference variables!
    Take the code Salima wrote, and observe the lines:
    5. System.out.print((("A"+"B")=="AB") + ",");
    6. System.out.print(("A"+"B")==(a+b));
    At line 5, the expression within the parenthesis is completely evaluatable at compile time! So it will be, and the resulting string will be imutably put in the pool of strings. If it already exists, no other copy is made!! The SAME string is reused.
    At line 6, within the second parenthesis, we have variables!! Who can garantee the values pointed by those variables!? Other object's method, for example, can change their values before execution reaches line 6!! Thus, not-immutable strings are created at runtime, not in the string pool, but in the heap!
    That's it, I guess...
    Hi...
    I think that's because of the overloaded form of the '+' operator. When one of its operands is a String, the other operand will be somehow transformed to a String. Literal values will become a String representation of them... and objects in general will have their toString() method called.
    The toString() method of an object of tipe Boolean returns a String representing the encapsulated value.
    If I said anything stupid please help me telling...
    Thanx