Article View: borland.public.jbuilder.java.swing
Article #8129Re: two questions about action
From: Randy
Date: Fri, 03 Nov 2000 00:00
Date: Fri, 03 Nov 2000 00:00
69 lines
3813 bytes
3813 bytes
this is what i get; not sure if it's right or not
IN actionPerformed: java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=By
Ledger] on
javax.swing.JMenuItem[,1,3,95x21,alignmentX=null,alignmentY=null,border=java
x.swing.plaf.metal.MetalBorders$MenuItemBorder@641e9a,flags=1056,maximumSize
=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIco
n=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=2,bottom=2,right=2],p
aintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rollover
Icon=,rolloverSelectedIcon=,selectedIcon=,text=By Ledger]
Action.NAME: Name
"Joi Ellis [TeamB]" <joi@aravox.com> wrote in message
news:8tvah9$7i310@bornews.borland.com...
> Randy <slyfox65@netzero.net> wrote:
> > it execute the entire dialog constructor, but nothing is shown.
>
> Well, yes. The JournalAction constructor will run when you first create
> the instance, with the line:
>
> dateAction = new JournalAction("viewByDate",this);
>
> This does not test the need for the menu item itself to properly trigger
> the actionPerformed method on Journal_Ledger itself. This is what I think
> is failing.
>
> Here is what I was suggesting you try changing:
>
> public class JournalAction extends AbstractAction {
> private Journal_Ledger target;
>
> public JournalAction(String name,Journal_Ledger comp) {
> putValue(Action.NAME,name);
> target = comp;
> }
>
> public void actionPerformed(ActionEvent evnt) {
> // ADD THE NEXT TWO LINES and the other prints, too.
> System.out.println("IN actionPerformed: " + evnt.toString());
> System.out.println("Action.NAME: " + Action.NAME);
> if(getValue(Action.NAME) == "viewByLedger") {
> target.test();
> System.out.println("target.test triggered");
> }
> else if(getValue(Action.NAME) == "viewByDate") {
> target.viewRecord(1);
> System.out.println("target.viewRecord triggered");
> }
> /**@todo: implement this javax.swing.AbstractAction abstract method*/
>
> }
> }
>
> If you invoke your menu item and you don't see the print statement, then
> your menu item isn't listening to the correct thing.
>
> If it does print, look carefully at the contents of the event object and
> see if it contains what you expected it to contain.
>
> Question: in viewRecord() you have a jif.show(), and then you add it to
> the JFrame's contentPane. Might the contentPane not be invalidating at
> this point? I don't know if this is good or not, I still resort to trial
> and error more than I care to when it comes to packing frames. (This is
> one place where Perl/tk beats out java...there's only one pack() trigger,
> rather than pack(), validate(), invalidate(), revalidate()....!)
>
> --
> Joi Ellis (TeamB)
> No direct email, please.
> For best results, post on news server newsgroups.borland.com!
Technical Details
Message-ID:
<8tvtfm$d9t5@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8tqo7u$n2b4@bornews.borland.com> <8tqqci$mv73@bornews.borland.com> <8ts088$5q67@bornews.borland.com> <8ts853$a9q7@bornews.borland.com> <8tsg26$a7315@bornews.borland.com> <8tshve$a6q11@bornews.borland.com> <8tt8sp$kmn2@bornews.borland.com> <8tteb8$kml7@bornews.borland.com> <8tunk0$3lm6@bornews.borland.com> <8tv4v6$7fc9@bornews.borland.com> <8tvah9$7i310@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,24022f34a2b35dbc X-Google-Attributes: gid111d45,public From: "Randy" <slyfox65@netzero.net> Subject: Re: two questions about action Date: 2000/11/03 Message-ID: <8tvtfm$d9t5@bornews.borland.com> X-Deja-AN: 689469978 References: <8tqo7u$n2b4@bornews.borland.com> <8tqqci$mv73@bornews.borland.com> <8ts088$5q67@bornews.borland.com> <8ts853$a9q7@bornews.borland.com> <8tsg26$a7315@bornews.borland.com> <8tshve$a6q11@bornews.borland.com> <8tt8sp$kmn2@bornews.borland.com> <8tteb8$kml7@bornews.borland.com> <8tunk0$3lm6@bornews.borland.com> <8tv4v6$7fc9@bornews.borland.com> <8tvah9$7i310@bornews.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing