Results 1 to 6 of 6
  1. #1
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Smile retrieve a value

    Good morning,

    I developed a java application,there are two classes : fenetre.java and parser.java.
    My class fenetre.java ,when i run it, i have an inerface which contains a button and a JTextField.
    retrieve a value-graphe.png

    My class parser.java contains main method and has an attribute named by : "chaine",his type is String.

    Well,now i want that when i write in the textField something,it will be retrived in the attribute "chaine",so that my class parser.java run using this value.

    Thank you

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: retrieve a value

    Quote Originally Posted by manou2324 View Post
    My class parser.java contains main method and has an attribute named by : "chaine",his type is String.

    Well,now i want that when i write in the textField something,it will be retrived in the attribute "chaine",so that my class parser.java run using this value.
    And your problem in doing that is ...?

    Do you know how to get the text from a text field?
    Do you know how to return a value from a method?
    Do you know how to pass a parameter to a method?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: retrieve a value

    Quote Originally Posted by DarrylBurke View Post
    And your problem in doing that is ...?

    Do you know how to get the text from a text field?
    Do you know how to return a value from a method?
    Do you know how to pass a parameter to a method?

    db

    "Do you know how to get the text from a text field?"
    ==> text = jtf.getText();

    Yes i know how to pass to a method and return from a method.

    But now,my class parser contains :
    public static void main(String[] args){...// the treatment in which i need the message written in the textField

    this is my problem

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: retrieve a value

    Well, to run a program you need only one main class (that is, one class that has a public static void main(String[] args) method.

    Having other classes with a main method doesn't harm anything though, so I still fail to understand where exactly you're stuck. A SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem might help you to get better help here.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: retrieve a value

    Thank you

    To make the problem more clear :
    my class parseur.java :

    public class parseur{

    public static void main (String [] args) throws IOException{

    String chaine = "";

    try
    {
    lecteurAvecBuffer = new BufferedReader(new FileReader("D:\\"+chaine+".txt"));
    }
    catch(FileNotFoundException exc) {......


    Now i need to bring "chaine" from a graphic interface: i need a textefield and a button so that when i clic that button i have the message in "chaine"

    I hope it is clear now and thank you

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: retrieve a value

    Quote Originally Posted by manou2324 View Post
    i clic that button i have the message in "chaine"
    Did you go through the SSCCE page?
    Do you know how to write code that gets executed when a button is clicked?
    Do you know how to write a method that sets the value of a variable, and can be called from another class?

    Also, go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Retrieve file
    By mine0926 in forum NetBeans
    Replies: 2
    Last Post: 06-03-2011, 04:47 AM
  2. Retrieve value from JTable
    By mcdhappy80 in forum AWT / Swing
    Replies: 5
    Last Post: 12-01-2010, 04:35 AM
  3. retrieve OS architecture
    By jitheshmenon in forum Advanced Java
    Replies: 4
    Last Post: 08-21-2010, 06:52 PM
  4. Retrieve Multidimensional Array ??
    By oneofthelions in forum New To Java
    Replies: 3
    Last Post: 12-12-2009, 07:24 AM
  5. How to retrieve data from servlet
    By valery in forum Java Servlet
    Replies: 1
    Last Post: 08-06-2007, 08:25 PM

Posting Permissions

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