🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #841

Action Problem

#841
From: Guillermo
Date: Mon, 27 Sep 2004 01:57
107 lines
4682 bytes
Hi,
I defined a simple action class (AccionAlta) to test actions functionality;
when I create a button in another Frame class (FrameBanco) referencing the
action class, I get the following error:

Hit uncaught exception java.lang.ClassCastException
java.lang.ClassCastException
 at javax.swing.AbstractButton.configurePropertiesFromAction(Unknown Source)
 at javax.swing.AbstractButton.configurePropertiesFromAction(Unknown Source)
 at javax.swing.JMenuItem.configurePropertiesFromAction(Unknown Source)
 at javax.swing.AbstractButton.setAction(Unknown Source)
 at javax.swing.JMenuItem.<init>(Unknown Source)
 at lyr.FrameBanco.<init>(FrameBanco.java:31)
 at lyr.FrameMain.jMenuBancos_actionPerformed(FrameMain.java:138)
 at
lyr.FrameMain_jMenuBancos_actionAdapter.actionPerformed(FrameMain.java:188)
 at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
 at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown
Source)
 at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
 at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
 at javax.swing.AbstractButton.doClick(Unknown Source)
 at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
 at
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Unkno
wn Source)
 at java.awt.Component.processMouseEvent(Unknown Source)
 at java.awt.Component.processEvent(Unknown Source)
 at java.awt.Container.processEvent(Unknown Source)
 at java.awt.Component.dispatchEventImpl(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
 at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
 at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 at java.awt.Window.dispatchEventImpl(Unknown Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at java.awt.EventQueue.dispatchEvent(Unknown Source)
 at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 at java.awt.EventDispatchThread.run(Unknown Source)

----------
The Action Class is:

package lyr;

import javax.swing.*;
import java.awt.event.*;

public class AccionAlta extends AbstractAction
{

  public AccionAlta()
  {
    putValue(Action.NAME, "Alta");
    putValue(Action.SMALL_ICON, "icons/db insert.bmp");
    putValue(Action.SHORT_DESCRIPTION, "Alta" );
    putValue(Action.LONG_DESCRIPTION, "Alta de un nuevo registro");
    putValue(Action.MNEMONIC_KEY, "A");
    putValue(Action.ACTION_COMMAND_KEY, "Comando Alta");
  }

  public void actionPerformed(ActionEvent e)
  {
    JOptionPane.showMessageDialog(null,"Acci�n Alta!",
"Hey!",JOptionPane.INFORMATION_MESSAGE);
  }
}

-----
The error arises in the last line of the following code of FrameBanco class,
that references the action class:

package lyr;

import javax.swing.*;
import java.awt.*;
import com.borland.dx.dataset.DataModule;
import com.borland.dbswing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;


public class FrameBanco
    extends JFrame
{

  AccionAlta accionAlta = new AccionAlta();

  protected DataModuleLyR dataModuleLyR;
  BorderLayout borderLayout2 = new BorderLayout();
  JMenuBar jMenuBarBanco = new JMenuBar();
  JMenu jMenuArchivo = new JMenu();
  JMenuItem jMenuItemSalida = new JMenuItem();
  JMenu jMenuEdicion = new JMenu();
  JMenuItem jMenuItemAlta = new JMenuItem(accionAlta);  // Error

------------

I appreciate any help please.

Thank you,
Guillermo
Technical Details
Message-ID: <41577352@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,4314440d03110928,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII
From: "Guillermo" <gnajar@gnsis.net>
Newsgroups: borland.public.jbuilder.java.swing
Subject: Action Problem
Date: Sun, 26 Sep 2004 21:57:42 -0400
Lines: 109
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 200.112.77.135
Message-ID: <41577352@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096250194 200.112.77.135 (26 Sep 2004 18:56:34 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail