Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

method not found error

Posted on 2004-04-19
4
387 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

856 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