Results 1 to 2 of 2
  1. #1
    AmyHill is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default ActionListener new user

    I have an address applet that I have an actionlistener and I'm having a problem getting the syntax correct to convert a long to a int. I'm very new so here we go... the errors are in the try statement. Any ideas?

    jbtSearch.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {

    try {Long searchPosition =;
    String seek = jtfSearch.getText();
    Integer seek = Integer.parseInt(seek.trim())-1;

    readAddress(searchPosition - 2 * RECORD_SIZE);
    if (searchPosition < 0)
    catch (IOException ex) {

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    You've got two different variables, seek, with the same name, and this may be causing your error.

    I recommend that you post your error messages with your question in the next go-around.

Similar Threads

  1. How to access the ActionListener
    By jboy in forum New To Java
    Replies: 3
    Last Post: 10-15-2009, 06:04 PM
  2. NullPointerException by ActionListener
    By YouGina in forum AWT / Swing
    Replies: 8
    Last Post: 07-10-2009, 11:08 AM
  3. Demonstrating the ActionListener
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 04-23-2008, 08:20 PM
  4. How to use KeyListener and ActionListener
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 08:19 PM
  5. ActionListener interface
    By tsantana in forum New To Java
    Replies: 2
    Last Post: 03-30-2008, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts