Article View: borland.public.jbuilder.java.swing
Article #8124Re: two questions about action
From: Joi Ellis [TeamB]
Date: Fri, 03 Nov 2000 00:00
Date: Fri, 03 Nov 2000 00:00
56 lines
2965 bytes
2965 bytes
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:
<8tvah9$7i310@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>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,24022f34a2b35dbc
X-Google-Attributes: gid111d45,public
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: two questions about action
Date: 2000/11/03
Message-ID: <8tvah9$7i310@bornews.borland.com>
X-Deja-AN: 689379753
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>
Organization: Another Netscape Collabra Server User
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.14-5.0 (i686))
Newsgroups: borland.public.jbuilder.java.swing