Results 1 to 3 of 3
  1. #1
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Arrow GUI problem when call another class

    hi,
    here is the GUI class, when i click the Button its calling a method from different class and show Results in TextArea correctly.
    Java Code:
    public class MainGui extends JFrame implements ActionListener
    {
    JButton myButton = new JButton("Button");
    JTextArea txtArea = new JTextArea("");
    JTextField txtField=new JTextField();
    ..
    ..
      public MainGui()
      {
    ..
    ..
      }
     
    public void actionPerformed(ActionEvent e)
      {
        if (e.getSource() == myButton)
    
    { SearchCompare sc= new SearchCompare();
    txtArea.setText(sc.process());}
    Here is the method in 'SearchCompare' class that works as a small search engine....
    Java Code:
    public class SearchCompare{ 
    ..
    public String process(){
    String showResult="";
    ...
    ...
    [B]String searchName="abc"; [/B]
    
    for (String found: names.keySet()) {
    File file = names.get(found); 
    double compare = SearchCompareBig.LCS(found, searchName);
    showResult+=found+"\t"+compare+"\t"+file.getName()+"\n";
    }
     
    return showResult; 
    }

    now, i want this 'searchName' String will get from TextField of MainGui and whatever the output generates will show results in TextArea of MainGui.

    i made like this:
    Java Code:
    //String searchName="abc";
    MainGui myGui=new MainGui();
    String searchName=myGui.txtField.getText();
    no error but no ouput in TextArea....
    where should i change the code pls help...
    what we are thinking, it might not be true

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Change this
    Java Code:
    public String process(){
    to this
    Java Code:
    public String process(String searchName){
    and pass the contents of the textfield.

  3. #3
    doha786 is offline Member
    Join Date
    Mar 2009
    Posts
    48
    Rep Power
    0

    Default

    great... thanks a lot.

    really appreciate you....
    what we are thinking, it might not be true

Similar Threads

  1. How can I call abstract class methods from another class
    By srinivas2828 in forum New To Java
    Replies: 13
    Last Post: 03-12-2010, 02:33 PM
  2. need help to call another class
    By doha786 in forum New To Java
    Replies: 2
    Last Post: 03-08-2010, 10:40 AM
  3. How can I call method from class in other class??
    By Hisham in forum New To Java
    Replies: 6
    Last Post: 02-14-2010, 03:49 PM
  4. How do I call a class in jsp page
    By Greg in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 09-20-2009, 10:27 PM
  5. Can I call directly the *.class
    By doanhanam in forum New To Java
    Replies: 1
    Last Post: 11-16-2008, 07:24 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
  •