Results 1 to 3 of 3
- 03-16-2010, 07:31 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
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.
Here is the method in 'SearchCompare' class that works as a small search engine....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());}
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:
no error but no ouput in TextArea....Java Code://String searchName="abc"; MainGui myGui=new MainGui(); String searchName=myGui.txtField.getText();
where should i change the code pls help...what we are thinking, it might not be true
- 03-16-2010, 07:53 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Change this
to thisJava Code:public String process(){
and pass the contents of the textfield.Java Code:public String process(String searchName){
- 03-16-2010, 08:29 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
Similar Threads
-
How can I call abstract class methods from another class
By srinivas2828 in forum New To JavaReplies: 13Last Post: 03-12-2010, 02:33 PM -
need help to call another class
By doha786 in forum New To JavaReplies: 2Last Post: 03-08-2010, 10:40 AM -
How can I call method from class in other class??
By Hisham in forum New To JavaReplies: 6Last Post: 02-14-2010, 03:49 PM -
How do I call a class in jsp page
By Greg in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 09-20-2009, 10:27 PM -
Can I call directly the *.class
By doanhanam in forum New To JavaReplies: 1Last Post: 11-16-2008, 07:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks