🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17220

listening for a button action

#17220
From: Matthew Wegener
Date: Thu, 03 Dec 1998 00:00
68 lines
2917 bytes
I'm recently obtained the source for an irc client app, and I'm trying
to make a modification to it to make the program listen for the click of
a "Send" button to send the text in the text input field to the server
rather than waiting for a CR/LF keyDown().

The textinput field is defined in method dinput in the DropInput class
which extends panel.  The DropInput method is then called from the input
method which is defined in the input class which also extends Panel.

so as things are placed, DropInput (panel) is added to another panel
which is then added to a card then shown.  this takes place in two (of
several) different .java files.  I can add the button to the DropInput
panel right along with the textInput field without any problems, but
where do I put the "implements Action Listener", and then the
"actionPerformed(ActionEvent event)" method?  these obviously have to
correspond with the definition and placement of the button, but when i
put in the code how I think it should be and get it to compile, I get a
"NoClassDefFound error input", or a "security violation: method
verification error." (Netscape 4.0) I can't get anything from dbug (I
don't think it even works just sits there for a bit then flashed a blank
DOS window then its done), I'm obviously new at Java, but can anyone
please help?

This is a snippent of the DropInput.java file:

import java.awt.*;
import java.util.Vector;
import java.awt.event.*;
public class DropInput extends Panel implements ActionListener{

...

 public DropInput(Engine e) {
      mke = new Choice();
  input = new TextField();
    desc = new TextField();
   lines = new Vector();
    send = new Button("Send");
    send.addActionListener(this);
  setLayout(new GridLayout(1,5));
  add(mke);
    add(modl);
    add(year);
    add(part);
    add(input);
//    add(desc);
    add(send);

...

}

...

public void actionPerformed(ActionEvent event) {
   String last = year.getSelectedItem()+"|"+mke.getSelectedItem()+"|"+
      modl.getSelectedItem()+"|"+part.getSelectedItem()+"||";

        if (year.getSelectedIndex() != 0 && mke.getSelectedIndex() != 0
&&
            modl.getSelectedIndex() != 0 && part.getSelectedIndex() !=
0) {
 }
 else last = "";
//  return last;
  }

Thanks for any help!
Technical Details
Message-ID: <36670620.1FF245CD@isoftdata.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,380324c918ffd19d,start
X-Google-Attributes: gidf74b3,public
From: Matthew Wegener <mwegener@isoftdata.com>
Subject: listening for a button action
Date: 1998/12/03
Message-ID: <36670620.1FF245CD@isoftdata.com>
X-Deja-AN: 418377031
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: newsabuse@supernews.com
X-Trace: 912721210 V1ARDBBYK71BDCE67C usenet87.supernews.com
Organization: ISoft Data Systems, Inc.
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language