Re: Action listener issue
Tristan Richard <[email protected]>
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
Here is the class that call the render method :
/**
* JPEG option dialog
*
* @author Tristan RICHARD
*/
public class JpegOptions extends SwiXMLDialog {
/**
* Validates user settings. Has to be <code>public</code> because of
SwiXML use
*/
public JButton okButton;
/**
* Build Swing dialog with XUL
*/
public JpegOptions() {
try {
swix = new SwingEngine(this);
swix.render("com/soft/iseult/iseult/gui/dialogs/JpegOptions.xml");
dialog = (JDialog) swix.getRootComponent();
initUI(); //Method to add more complex UI elements to the already
created XUL one
dialog.pack();
} catch (Exception e) {
e.printStackTrace();
}
}
The okButton works very well, and in initUI(), you have a classic Action
Listener :
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exit();
}
});
But for the cancel action, everything is defined in SwiXMLDialog
abstract class. It is public, so there shall not be any trouble using it
from XUL.
ABout the jre, I have the same issue on Windows and Linux, and also with
j2re 1.4.2_03, so I guess it comes not from there. But I don't
understand why it works from Eclipse and not outside of it ?
Regards,
Tristan
Frank Meissner a écrit :
> Tristan Richard wrote:
>
>> Hi,
>>
>> I have created an abstract dialog class for dialogs based on Swixml,
>> with a public cancelAction. (see below)
>>
>> So that I can call it from my XUL code like that :
>> <button text="dialog.cancel" action="cancelAction"/>
>>
>> /**
>> * This class merely defines what we need to create
>> * a dialog box with SwiXML
>> *
>> * @author Tristan RICHARD
>> */
>> public abstract class SwiXMLDialog {
>>
>> /**
>> * Rendering engine from XUL to Swing
>> */
>> SwingEngine swix;
>>
>> public Action cancelAction = new AbstractAction() {
>> public void actionPerformed(ActionEvent e) {
>> dialog.dispose();
>> }
>> };
>>
>> /**
>> * The top UI <code>Container</code> to represent this class
>> */
>> JDialog dialog;
>> ...
>>
>> There's something strange out there:
>> When I'm using Eclipse, and jre 1.4.2_04 from Sun, I have no pb.
>> But when my app is launched directly with the same jre, outside
>> Eclipse, the button doesn't execute the action code...
>>
>> I assume there is a problem in action listener registration by Swix?
>
>
> Hm, this sounds rather strange. I do not know of any 1.4.2_04 specific
> issues there. I'm using eclipse to develop swixml applications quite
> seriously and did not have any problems there either...
>
> Please post the swix.render(...) call. I suspect a problem there.
>
> Frank
>
>> The problem doesn't happen if I set explicitely the action listener in
>> the Java code, which I'd like to avoid.
>>
>> Can anyone help ?
>>
>> Thx,
>> Tristan Richard
>>
>>
>> _______________________________________________
>> Forum mailing list
>> [email protected]
>> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
>>