Hi all,
nice to see this list active again and new projects in motion. how can I return the filename to the caller program, the u/m code is called when the menubar item or toolbar button is pressed, this obtains the zip file which is what I want to have access to in the caller program. can this method return the variable zps (in this example) or is there another way where I can access this fm the caller program. as always , any help is appreciated. PS: I am an eComStation (OS/2) user so all new stuff being discussed here will also be tried on this OS and feedback given. class eZE.OpenAction dependent extends AbstractAction method OpenAction( text = String, icon = ImageIcon ) super( text, icon ) method actionPerformed( e = ActionEvent ) public -- load file chooser using filters fc = JFileChooser( "d:\\download" ) fc.setFileSelectionMode( JFileChooser.FILES_ONLY ) fc.setAcceptAllFileFilterUsed( 0 ) fc.addChoosableFileFilter( MyFilter() ) -- open file chooser returnedval = fc.showOpenDialog( parent.mainwindow ) -- query the filechooser to get user input if returnedval = JFileChooser.APPROVE_OPTION then do zp = fc.getSelectedFile() zf = ZipFile( zp ) entries = zf.entries() -- store total entires into variable zipentries = zf.size() -- set out conter i = 0 -- convert selected archive to string format zps = zp.toString() loop while entries.hasMoreElements() ze = ZipEntry entries.nextElement() ... ... ... end catch e=IOException say "Open Zip Error ==>"||e end -- update status bar with archive information parent.sb.setMessage( zps ) parent.sbrb.setMessage( zipentries||" files" ) return -------------- next part -------------- An HTML attachment was scrubbed... URL: http://ns.hursley.ibm.com/pipermail/ibm-netrexx/attachments/20100205/013f6017/attachment.html |
Quique,
I'm afraid actionPerformed's signature may not be modified without breaking the interface. Note also there is no concept of calling programm involved here. Your action event code will get called at appropiate time by the event dispatch thread on "swing's runtime". Returning some value would not make much sense.. One possible alternative would be getting a reference to the object on which the ActionEvent occurred, then calling some setter method implemented on it or calling some arbitrary handling method. To access originating object you call getSource on the ActionEvent object (here that would be e.getSource) and cast it to propitiate class. Hope that helps. 2010/2/5 Quique Britto <[hidden email]> > Hi all, > > nice to see this list active again and new projects in motion. > > how can I return the filename to the caller program, the u/m code is called > when the menubar item or toolbar button is pressed, this obtains the zip > file which is what I want to have access to in the caller program. > > can this method return the variable zps (in this example) or is there > another way where I can access this fm the caller program. > > as always , any help is appreciated. > > > PS: I am an eComStation (OS/2) user so all new stuff being discussed here > will also be tried on this OS and feedback given. > > > > class eZE.OpenAction dependent extends AbstractAction > method OpenAction( text = String, icon = ImageIcon ) > super( text, icon ) > > method actionPerformed( e = ActionEvent ) public > -- load file chooser using filters > fc = JFileChooser( "d:\\download" ) > fc.setFileSelectionMode( JFileChooser.FILES_ONLY ) > fc.setAcceptAllFileFilterUsed( 0 ) > fc.addChoosableFileFilter( MyFilter() ) > > -- open file chooser > returnedval = fc.showOpenDialog( parent.mainwindow ) > > -- query the filechooser to get user input > if returnedval = JFileChooser.APPROVE_OPTION then > do > zp = fc.getSelectedFile() > zf = ZipFile( zp ) > entries = zf.entries() > > -- store total entires into variable > zipentries = zf.size() > > -- set out conter > i = 0 > > -- convert selected archive to string format > zps = zp.toString() > > loop while entries.hasMoreElements() > ze = ZipEntry entries.nextElement() > ... > ... > ... > end > > catch e=IOException > say "Open Zip Error ==>"||e > > end > > -- update status bar with archive information > parent.sb.setMessage( zps ) > parent.sbrb.setMessage( zipentries||" files" ) > > return > > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > -- Saludos / Regards, David Requena -------------- next part -------------- An HTML attachment was scrubbed... URL: http://ns.hursley.ibm.com/pipermail/ibm-netrexx/attachments/20100205/e12d824d/attachment-0001.html |
makes sense, thanks.
On 5 February 2010 13:22, David Requena <[hidden email]> wrote: > Quique, > > I'm afraid actionPerformed's signature may not be modified without breaking > the interface. > > Note also there is no concept of calling programm involved here. Your > action event code will get called at appropiate time by the event dispatch > thread on "swing's runtime". Returning some value would not make much > sense.. > > One possible alternative would be getting a reference to the object on > which the ActionEvent occurred, then calling some setter method implemented > on it or calling some arbitrary handling method. To access originating > object you call getSource on the ActionEvent object (here that would be > e.getSource) and cast it to propitiate class. > > Hope that helps. > > 2010/2/5 Quique Britto <[hidden email]> > >> Hi all, >> >> nice to see this list active again and new projects in motion. >> >> how can I return the filename to the caller program, the u/m code is >> called when the menubar item or toolbar button is pressed, this obtains the >> zip file which is what I want to have access to in the caller program. >> >> can this method return the variable zps (in this example) or is there >> another way where I can access this fm the caller program. >> >> as always , any help is appreciated. >> >> >> PS: I am an eComStation (OS/2) user so all new stuff being discussed here >> will also be tried on this OS and feedback given. >> >> >> >> class eZE.OpenAction dependent extends AbstractAction >> method OpenAction( text = String, icon = ImageIcon ) >> super( text, icon ) >> >> method actionPerformed( e = ActionEvent ) public >> -- load file chooser using filters >> fc = JFileChooser( "d:\\download" ) >> fc.setFileSelectionMode( JFileChooser.FILES_ONLY ) >> fc.setAcceptAllFileFilterUsed( 0 ) >> fc.addChoosableFileFilter( MyFilter() ) >> >> -- open file chooser >> returnedval = fc.showOpenDialog( parent.mainwindow ) >> >> -- query the filechooser to get user input >> if returnedval = JFileChooser.APPROVE_OPTION then >> do >> zp = fc.getSelectedFile() >> zf = ZipFile( zp ) >> entries = zf.entries() >> >> -- store total entires into variable >> zipentries = zf.size() >> >> -- set out conter >> i = 0 >> >> -- convert selected archive to string format >> zps = zp.toString() >> >> loop while entries.hasMoreElements() >> ze = ZipEntry entries.nextElement() >> ... >> ... >> ... >> end >> >> catch e=IOException >> say "Open Zip Error ==>"||e >> >> end >> >> -- update status bar with archive information >> parent.sb.setMessage( zps ) >> parent.sbrb.setMessage( zipentries||" files" ) >> >> return >> >> >> _______________________________________________ >> Ibm-netrexx mailing list >> [hidden email] >> >> >> > > > -- > Saludos / Regards, > David Requena > > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > An HTML attachment was scrubbed... URL: http://ns.hursley.ibm.com/pipermail/ibm-netrexx/attachments/20100205/24da4e36/attachment.html |
Free forum by Nabble | Edit this page |