Breaking News: Java Entangles Brain of Brasilian Student

Discussion in 'Computer Science & Culture' started by TruthSeeker, Oct 7, 2004.

Thread Status:
Not open for further replies.
  1. TruthSeeker Fancy Virtual Reality Monkey Valued Senior Member

    Messages:
    15,162
    Altough I got an A+ in my Java class, I just started studying events and they are quite confusing. I think the most confusing thing is that I have to get a variable, and assign different names for it, in different methods. That sucks! It's very confusing. Like for example...

    First I have to assign it a name in the class:

    "TextField text;"

    Then, in the initialize method, I try to create a text box:

    "public void init(){
    text= new TextField(" ",15);
    add(text);
    text.addActionListener(this);
    }"


    Now, the confusion begins. I have to assign another name for the same damn thing:

    "public void actionPerformed(ActionEvent e){
    newtext= text.getText();
    repaint();
    }"


    Then, after I add new stuff like scrollbars and so on, it is pretty hard to keep track of which thing goes with which!

    Please Register or Log in to view the hidden image!



    Aaaaaaaaahhhhhh!

    Please Register or Log in to view the hidden image!


    Any insights!?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Athelwulf Rest in peace Kurt... Registered Senior Member

    Messages:
    5,060
    Ditch Java, dude, if it's confusing ya that much!
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Voodoo Child Registered Senior Member

    Messages:
    1,296
    It is not the same damn thing: text.getText() is a method returning a string. text is a textField that has many methods and properties.

    There is no real need to assign a new name, unless you want to manipulate the string separately. Then, of course, this makes sense since you have two sets of information.

    Ah, the perils of the the java GUI. I recommend gaining a basic understanding of event handling and swing principles and then start using an IDE's drag and drop features. It also helps if you very descriptively name you components.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Athelwulf Rest in peace Kurt... Registered Senior Member

    Messages:
    5,060
    Is Java, by chance, a computer language for making web pages? It looks like that to me from the samples ya've posted. And if so, can ya insert comments to yerself that a browser ignores? I use HTML and JavaScript, and I can put comments that the browser passes over in both of them.

    If ya can put in comments to yerself, just use that to show where everything is.
     
  8. Stryder Keeper of "good" ideas. Valued Senior Member

    Messages:
    13,105
    I guess you are suggesting he leaves commented notes throughout his coding, or potentially comment a piece of the code out to test what it does.

    Java itself isn't directly interpretable by the web-browser so it has to use plugins to run pre-written applets, it's similar to C++ in some senseand has the capacity to do alot of things that couldn't originally be done on the internet via HTML and Javascript/JScript or VBScript.

    In fact originally webdesigners avoided Java because it was too labour intensive to the CPU's at the time (You needed at least a 233Mhz machine to be able to run most small applets otherwise it would cause problems when attempting to view). Luckily now adays the systems have grown exponentially and are capable of using Java how it was suppose to be used, although such plugins like Shockwave/Flash have now become more popular with Active scripting for most of the presentations.

    Java still however has the capacity to act as a Cross-Platform tie over, especially with WebTV, mobile phones and PDA's (Which it was really kind of developed for)
     
  9. TruthSeeker Fancy Virtual Reality Monkey Valued Senior Member

    Messages:
    15,162
    Thankx for the comments

    I think I found what I was doing not so right. I think I will be commenting a lot more and using some indentention. Maybe I should divide it into "chapters" like "declarations", "initializing input" and "repainting output"......

    Oh well... :m:

    Kind of develop for? Well, it was actually totally developed for that. The reason why Java is so popular it is because it has the industry strenght of C++ with the simplicity of web languages.

    Please Register or Log in to view the hidden image!



    And it is also very versatile....

    Java is one of those great things that we have created over a cup of coffee...

    Please Register or Log in to view the hidden image!

     
  10. TruthSeeker Fancy Virtual Reality Monkey Valued Senior Member

    Messages:
    15,162
    Java is not quite for webpages

    Please Register or Log in to view the hidden image!


    But yeah... I can use comments. And I have used them before. But once I learnt events, I learnt quite a few new methods and statements. Which is why my programming got soooooooo messy...

    Please Register or Log in to view the hidden image!



    Comments are a little bit different in Java (compared to the web ones)...
    It is just like this: // or this: /*...*/ .... Like in CSS...

    Please Register or Log in to view the hidden image!

     
Thread Status:
Not open for further replies.

Share This Page