Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Unhappy How to Use Actions

    Hello. I have spent quite a few hours trying to follow an API on how to use Actions in a java program.

    I have 3 JButtons and have just added a JMenu. What I want to do is to add an ACTION so that the JMenu performs the same function as the JButtons. (i.e. they both do the same thing).

    I have tried to copy and follow the example from the API forum.
    How to Use Actions (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

    The first error I get in compiling is on the following line:

    Action loadFile = new LOADFILE();

    However, I get the following error message:
    softeng2final2.java:49: cannot find symbol
    symbol : class LOADFILE
    location: class softeng2final2
    Action loadFile = new LOADFILE();
    ^
    When I later define LOADFILE
    LOADFILE= new AbstractAction(null,null){

    I get the error message:
    softeng2final2.java:108: cannot find symbol
    symbol : variable LOADFILE
    location: class softeng2final2
    LOADFILE= new AbstractAction(null,null){
    ^

    Please can anyone help???:eek:

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by AJArmstron@aol.com View Post
    Hello. I have spent quite a few hours trying to follow an API on how to use Actions in a java program.

    I have 3 JButtons and have just added a JMenu. What I want to do is to add an ACTION so that the JMenu performs the same function as the JButtons. (i.e. they both do the same thing).

    I have tried to copy and follow the example from the API forum.
    How to Use Actions (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

    The first error I get in compiling is on the following line:

    Action loadFile = new LOADFILE();

    However, I get the following error message:
    softeng2final2.java:49: cannot find symbol
    symbol : class LOADFILE
    location: class softeng2final2
    Action loadFile = new LOADFILE();
    ^
    When I later define LOADFILE
    LOADFILE= new AbstractAction(null,null){

    I get the error message:
    softeng2final2.java:108: cannot find symbol
    symbol : variable LOADFILE
    location: class softeng2final2
    LOADFILE= new AbstractAction(null,null){
    ^

    Please can anyone help???:eek:
    The compiler simply can't find the identifier LOADFILE, neither as a class (the first time it complained) nor as a variable name (the second time it complained).

    kind regards,

    Jos

  3. #3
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Default

    Why can't it find it? It's very visible to me!!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by AJArmstron@aol.com View Post
    Why can't it find it? It's very visible to me!!
    But it's not visible to us.

  5. #5
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    I have tried to copy and follow the example from the API forum.
    How to Use Actions (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)
    I don't know did you noticed that you had full code on that page "ActionDemo.java" (I think you did). If you did not here is link:
    http://java.sun.com/docs/books/tutor...ctionDemo.java

    When I run that code I have this notification:
    Resource not found: toolbarButtonGraphics/navigation/Back24.gif
    Resource not found: toolbarButtonGraphics/navigation/Up24.gif
    Resource not found: toolbarButtonGraphics/navigation/Forward24.gif
    that means everything is fine, but you don't have gif pictures Back24.gif, Up24.gif, and Forward24.gif. If you provide them you will not have any error.

Similar Threads

  1. JMenuItems and actions
    By Kligham in forum New To Java
    Replies: 5
    Last Post: 01-05-2010, 05:00 PM
  2. Button Actions
    By vasavi.singh in forum Advanced Java
    Replies: 3
    Last Post: 04-03-2009, 09:50 PM
  3. various actions in menuitem of popupmenu
    By Peggy in forum Java Applets
    Replies: 0
    Last Post: 12-11-2008, 11:50 AM
  4. Actions
    By alley in forum AWT / Swing
    Replies: 2
    Last Post: 01-16-2008, 02:52 PM
  5. Bean related actions in JSP
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 10:04 AM

Posting Permissions

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