Results 1 to 4 of 4
  1. #1
    McArthurG is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default how to connect 2 java files

    hi, i'm new to java and im using netbeans. i'm wondering if there's a way for 2 java files let's say A and B. using netbeam's ui editor i made 3 jbuttons on A and a textfield on B, i can make B appear once i click any of the buttons on A but what i wanted to do was make the textfield change value depending on which of the 3 buttons were pressed.

    any help is appreciated, thank you

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    12

    Default

    Quote Originally Posted by McArthurG View Post
    hi, i'm new to java and im using netbeans.
    Not good!
    Quote Originally Posted by McArthurG View Post
    i'm wondering if there's a way for 2 java files let's say A and B. using netbeam's ui editor
    Worse!
    Quote Originally Posted by McArthurG View Post
    i made 3 jbuttons on A and a textfield on B, i can make B appear once i click any of the buttons on A but what i wanted to do was make the textfield change value depending on which of the 3 buttons were pressed.
    any help is appreciated, thank you
    You have your main class (C) which contains an instance of JFrame, an instance of A and an instance B. I suppose A implements ActionListener to register the button events. Either you let C implement the ActionListener and on the events you take your B reference and set the text, or you pass the B reference to the A reference and set the text in there.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    McArthurG is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    actually the scope of what im doing is bigger but my example is sort of the jist, anyway the reason im using netbeans ui editor is so i can present what it's gona look like.


    under the action listener from A (the one with buttons) i made an instance of B and i tried doing the B.jTextfield.setText...

    but netbeans doesnt show the auto suggest while im typing B.(variables should be auto suggested after typing "B." right?) i've done smethng like this before i just can't figure out why i can't do it now

    thnks for the fast reply

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    12

    Default

    Well B is the class, you need the exact reference that is used in your JFrame, not any reference to B. So as I've already suggested, pass the b reference into your a refernce and use it there.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. connect to oracle from java
    By ahmadian in forum Advanced Java
    Replies: 7
    Last Post: 05-15-2013, 04:15 PM
  2. Replies: 8
    Last Post: 07-30-2010, 05:47 PM
  3. one file connect with another files
    By ramanavarayuri in forum AWT / Swing
    Replies: 2
    Last Post: 10-22-2009, 05:19 PM
  4. conversion of java .class files to .java files
    By kotturupraveen in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 12:58 PM
  5. Making connect 4 in java
    By zoe in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •