Re: Jython actions
kate rhodes <[email protected]>
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
it's all based on reflection...if your jython class has an object, of the appropriate type that can be seen via reflection then you're golden. if not, you can't use SWIXML. EVERYTHING is done via reflection. you need publically visible java objects that extend AbstractAction that can be seen with reflection. you may be able to work around this by using instanceof. I haven't really used instance of though so I can't comment. -Kate Abiel Hakeem wrote: > Dear all, I am using jython for faster java apps development.. I just > want to ask you how to implements 'Actions' defined in SwiXML tag for > Jython?? > > Thanks! > > ps: I am attaching my failed jython program when trying to invoke an > action > > > > > ------------------------------------------------------------------------ > > #Accelerator.py > #jython test version > #I love coding but I am a fucking lazy programmer! > from org.swixml import SwingEngine > > from javax.swing import * > from java.awt.event.ActionEvent import * > > class new_action(AbstractAction): > #def __init__(self): > # AbstractAction.__init__(self) > def actionPerformed(self,e ): > print "hello" > > > class Accelerator: > def __init__(self): > self.DESCRIPTOR = "xml/accelerator.xml" > self.swix=SwingEngine(self) > self.swix.render( self.DESCRIPTOR ).setVisible( 1 ) > self.newAction=new_action() > > def aboutAction(self,e): > JOptionPane.showMessageDialog( self.swix.getRootComponent(), "Sorry, not implemented yet." ) > > > if __name__=='__main__': > accel=Accelerator() > > > > > > ------------------------------------------------------------------------ > > <?xml version="1.0" encoding="UTF-8"?> > > <frame name="mainframe" size="640,480" title="S W I X M L" plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"> > > <menubar name="menubar"> > > <menu name="filemenu" text="File"> > > <menuitem name="mi_new" text="New" icon="icons/new.gif" mnemonic="VK_N" accelerator="control N" Action="newAction"/> > > <menuitem name="mi_open" text="Open" icon="icons/open.gif" mnemonic="VK_O" Accelerator="control O" ActionCommand="open"/> > > <menuitem name="mi_save" text="Save" icon="icons/save.gif" mnemonic="VK_S" ActionCommand="save"/> > > <separator/> > > <menuitem name="mi_exit" text="Exit" icon="icons/exit.gif" mnemonic="VK_X" Accelerator="control X" ActionCommand="exit"/> > > </menu> > > <menu text="Help"> > > <menuitem name="mi_about" text="About" enabled="true" icon="icons/info.gif" Accelerator="alt A" Action="aboutAction" /> > > </menu> > > </menubar> > > > > > > <panel layout="borderlayout" background="666666" constraints="BorderLayout.CENTER"> > > <splitpane oneTouchExpandable="true" dividerLocation="200"> > > <splitpane oneTouchExpandable="true" dividerLocation="140" orientation="HORIZONTAL"> > > <scrollPane> > > <tree name="tree"/> > > </scrollPane> > > <panel layout="borderlayout"> > > <panel constraints="BorderLayout.NORTH"> > > <button name="btn_copy" ToolTipText="JPanel" enabled="true" BorderPainted="false" FocusPainted="false" icon="icons/copy.gif" size="24,24"/> > > <button name="btn_paste" ToolTipText="JButton" enabled="true" BorderPainted="false" FocusPainted="false" icon="icons/paste.gif" size="24,24"/> > > <button name="btn_cut" ToolTipText="JLabel" enabled="true" icon="icons/cut.gif" BorderPainted="false" FocusPainted="false" size="24,24"/> > > </panel> > > <scrollPane constraints="BorderLayout.CENTER"> > > <table name="table"/> > > </scrollPane> > > </panel> > > </splitpane> > > <panel name="preview" border="LoweredBevelBorder"> > > <textarea name="ta"/> > > </panel> > > </splitpane> > > > > </panel> > > <panel constraints="BorderLayout.SOUTH"> > > <label text="Status:"/> > > <textfield text="OK"/> > > </panel> > > </frame> > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Forum mailing list > [email protected] > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com