Solved

method not found error

Posted on 2004-04-19
4
380 Views
Last Modified: 2013-11-23
Hi, i have a java file that contacts an rmi server and makes google based querys through that server. When I search the web (the server uses google) using the java gui I want each website address to be seperated by a new line but im getting this error:

--------------------Configuration: j2sdk1.4.0_02 <Default>--------------------
C:\ronaynea\Client.java:255: cannot resolve symbol
symbol  : method append  (java.lang.String)
location: class javax.swing.JTextField
                     search.append("\n");
                              ^
1 error

Process completed.

when I call this method: search.append("\n");

This is what im importing:
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.lang.*;
import javax.swing.*;

Some more more below if that helps,  the append method is included.

Thanks, any help at all would be brilliant.


  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
          try{
                if(ipAddress.equals("localhost"));
                       ipAddress =  jTextField5.getText();
        search.selectAll ();
                  String name = "//"+ipAddress+"/Server";
                  Serv dsProj = (Serv) Naming.lookup(name);

               String query = dsProj.webSearch(jTextField2.getText ());
               String tmp[] = query.split("#div#");
        for(int cnt = 0;cnt <tmp.length;cnt++){
                           search.replaceSelection (tmp[cnt]);
                     search.append("\n");
                     
        }        
       
    }
     catch(ConnectException ce){
            
            }catch(UnknownHostException uhe){
                  
            }catch(Exception e){
                  
            }
        }


////////////////The complete file just to be sure - kind of long but mostly just gui buttons///////////////////////////////
package GoogleSearch;

import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.lang.*;
import javax.swing.*;

public class Client extends javax.swing.JFrame {
       String ipAddress = new String("localhost");
       public String newip = "";
   
    /** Creates new form Project */
     public Client() {
        initComponents();
    }
   
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        search = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextArea1 = new javax.swing.JTextArea();
        jTextArea2 = new javax.swing.JTextArea();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextArea3 = new javax.swing.JTextArea();
        jTextField5 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jPanel1.setLayout(null);
 



        jButton1.setText("Web Search");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
       
 
        jPanel1.add(jButton1);
        jButton1.setBounds(510, 70, 100, 23);

        jButton2.setText("Spell Check");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel1.add(jButton2);
        jButton2.setBounds(530, 450, 89, 23);

        search.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchActionPerformed(evt);
            }
        });

        jPanel1.add(search);
        search.setBounds(60, 120, 430, 210);

        jTextField2.setText("");
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        jPanel1.add(jTextField2);
        jTextField2.setBounds(230, 70, 260, 20);

        jTextArea1.setText("Enter Search Query");
        jPanel1.add(jTextArea1);
        jTextArea1.setBounds(60, 70, 140, 17);

        jTextArea2.setText("Enter Word");
        jPanel1.add(jTextArea2);
        jTextArea2.setBounds(70, 450, 140, 17);

        jTextField3.setText("");
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jPanel1.add(jTextField3);
        jTextField3.setBounds(230, 450, 260, 20);

     

        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        jPanel1.add(jTextField4);
        jTextField4.setBounds(230, 500, 260, 20);

        jTextArea3.setText("Contact Server");
        jPanel1.add(jTextArea3);
        jTextArea3.setBounds(60, 20, 140, 17);

        jTextField5.setText("localhost");
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jPanel1.add(jTextField5);
        jTextField5.setBounds(230, 20, 260, 20);

        jButton3.setText("Submit");
       
        jPanel1.add(jButton3);
        jButton3.setBounds(510, 20, 100, 23);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        fileMenu.setText("File");
        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setText("Save As ...");
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });

        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText("Edit");
        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setText("Help");
        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        pack();
    }

  private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
 
    }

       
    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
           try{
                 if(ipAddress.equals("localhost"));
                       ipAddress =  jTextField5.getText();
                  String name = "//"+ipAddress+"/Server";
                  Serv dsProj = (Serv) Naming.lookup(name);

               String query = dsProj.webSpellCheck ( jTextField3.getText ());
               if(query == null){
                           jTextField4.setText(jTextField3.getText()+" spelt correctly");
               }
               else{
                           jTextField4.setText ("Correct Spelling? : "+query);
               }
        }catch(ConnectException ce){
                  jTextField4.setText(ce.getMessage()+"\nServer Is Not On Host "+ipAddress);      
            }catch(UnknownHostException uhe){
                jTextField4.setText(ipAddress+"IP Address is invalid, please re - enter");
            }catch(Exception e){
                  System.err.println("dsProjServer exception: "+ e.getMessage());
            }
    }

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void searchActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
          try{
                if(ipAddress.equals("localhost"));
                       ipAddress =  jTextField5.getText();
        search.selectAll ();
                  String name = "//"+ipAddress+"/Server";
                  Serv dsProj = (Serv) Naming.lookup(name);

               String query = dsProj.webSearch(jTextField2.getText ());
               String tmp[] = query.split("#div#");
        for(int cnt = 0;cnt <tmp.length;cnt++){
                           search.replaceSelection (tmp[cnt]);
                     search.append("\n");
                     
        }        
       
    }
     catch(ConnectException ce){
            
            }catch(UnknownHostException uhe){
                  
            }catch(Exception e){
                  
            }
        }
       

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        System.exit(0);
    }
   
    /**
     * @param args the command line arguments
     */
   public static void main(String args[]) {
           Client.setDefaultLookAndFeelDecorated(true);
        Client window = new Client();
        window.setSize (1000, 900);
        window.show ();
       
    }
    // Variables declaration - do not modify
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextArea jTextArea3;
    private javax.swing.JTextField search;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration
   
}
0
Comment
Question by:monitorscreen
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:gnoon
gnoon earned 25 total points
ID: 10865234
The search variable is JTextField and JTextField class *didn't have* append method (append is a method of JTextArea class) http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTextField.html.
However, you can use    search.setText( search.getText() + "\n" );  instead.
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 25 total points
ID: 10865664
You're mixing up JTextField and JTextArea, use JTextArea.append()

;JOOP!
0
 

Author Comment

by:monitorscreen
ID: 10866974
Thanks for the help but neither method worked for me

gnoon: your method compiled but didnt get executed.

sciuriware: your method threw an error at compilation.

0
 

Author Comment

by:monitorscreen
ID: 10867025

I got it, thanks a mllion for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 122
what is the difference between "sudo su" and "su - root" 6 106
Java / Linux and Regular Expressions 11 71
how to add new optional parameter to JSP 1 29
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now