Solved

method not found error

Posted on 2004-04-19
4
397 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
[X]
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
  • 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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