rodger rainier wants to share "Shared" with you

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

Robert L Hamilton
How does the Original Java Code compare w/ the JAVA Code produced by NetRexx?

Bob Hamilton
Richardson Texas USA

On Mon, Jan 16, 2012 at 1:04 PM, <[hidden email]> wrote:

Here is another sample from the java tutorial, converted to netrexx and working.

The conversion with java2nrx was fairly complete. A couple stray curly brackets survived. A couple properties keywords were superfluously created. The exception processing didn't compile so it's just commented out. And I still don't understand how the class "Runnable" works, but I just blindly followed Alan's tips like with ButtonDemo.

Is the source to java2nrx written in netrexx? Is it available?


01/16/2012 13:41
 > type FocusConceptsDemo.nrx
package misc

import java.awt.
import java.awt.event.
import javax.swing.

class FocusConceptsDemo public  extends JPanel

    properties static
    frame = JFrame

    properties
    t1 = JTextField
    t2 = JTextField
    t3 = JTextField
    t4 = JTextField

--    properties
    b1 = JButton
    b2 = JButton
    b3 = JButton
    b4 = JButton

--    properties
    text1 = JTextArea

    method FocusConceptsDemo
        super(BorderLayout())
        b1 = JButton("JButton")
        b2 = JButton("JButton")
        b3 = JButton("JButton")
        b4 = JButton("JButton")
        buttonPanel = JPanel
        buttonPanel = JPanel(GridLayout(1, 1))
        buttonPanel.add(b1)
        buttonPanel.add(b2)
        buttonPanel.add(b3)
        buttonPanel.add(b4)
        text1 = JTextArea("JTextArea", 15, 40)
        textAreaPanel = JPanel
        textAreaPanel = JPanel(BorderLayout())
        textAreaPanel.add(text1, BorderLayout.CENTER)
        t1 = JTextField("JTextField")
        t2 = JTextField("JTextField")
        t3 = JTextField("JTextField")
        t4 = JTextField("JTextField")
        textFieldPanel = JPanel
        textFieldPanel = JPanel(GridLayout(1, 1))
        textFieldPanel.add(t1)
        textFieldPanel.add(t2)
        textFieldPanel.add(t3)
        textFieldPanel.add(t4)
        add(buttonPanel, BorderLayout.PAGE_START)
        add(textAreaPanel, BorderLayout.CENTER)
        add(textFieldPanel, BorderLayout.PAGE_END)
        setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20))

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
method createAndShowGUI inheritable  static
        frame = JFrame("FocusConceptsDemo")
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        newContentPane = JComponent
        newContentPane = FocusConceptsDemo()
        newContentPane.setOpaque(isTrue)
        frame.setContentPane(newContentPane)
        frame.pack()
        frame.setVisible(isTrue)

method isTrue public static returns boolean
  return (1 == 1)

method isFalse public static returns boolean
   return \isTrue

method main( args=String[] ) static
--       do
             UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
--        catch  ex=UnsupportedLookAndFeelException
--           ex.printStackTrace()
--        catch  ex=IllegalAccessException
--           ex.printStackTrace()
--        catch  ex=InstantiationException
--           ex.printStackTrace()
--        catch  ex=ClassNotFoundException
--           ex.printStackTrace()
--       end
       UIManager.put("swing.boldMetal", Boolean.FALSE)
       javax.swing.SwingUtilities.invokeLater(FocusConceptsDemo.RunnableImp())


class FocusConceptsDemo.RunnableImp implements Runnable
method run public
    FocusConceptsDemo.createAndShowGUI()
        return


Kenneth Klein

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

ThSITC
In reply to this post by kenner
*really GREAT* conversation!

Thank you all!
Thomas.
O==)

Am 16.01.2012 16:31, schrieb [hidden email]

Would you tell us anything you find noteworthy about the experience?  About your programming experience?  A few (random) questions that spring to my mind:

1 Can you make some sense of Java code, perhaps because you have a C/C++ background?
2 Did you start the Tutorials with basics (Java types, syntax, etc) or jump directly to the Swing Tutorial?
3 How would you rate the quality of the Java Tutorial?
4 Can you interpret (perhaps partially) a Javadoc?

I've been programming since 1982. Even in those days we pushed "structured programming" in COBOL along the lines of OO in a way. Gotos and spaghetti code was tabu. I find JAVA very much like spaghetti code. Assembler coding was also very procedural, top down, you always new which instruction was next and traces made sense. I love(d) REXX from day one and have written 1000's of lines of add-hoc code for system utilities on the mainframe. I dabbled with C++ for a while and praise the use of functions like it does.

1) Java code is still mysterious even when I am looking at and tracing a working example. There is so much under the covers. Coding in Java is not programming, it is trying to second guess the infinitely wise designers of all these classes and subclasses and methods. At first I could not tell the java code from properties specific to the program I was looking at. Even the Netrexx code was a blur between what was a reserved word and field-name in this program. When you define methods and classes the source becomes the programming language.

2) I tried to start from the very beginning with the basics and you all know how it goes, I got impatient and just wanted to see something work. That's how I turned a java example using AboutFrame, Guiapp and actionlistener into a multiple choice quiz and a true or false quiz. When I got really bogged down I went back to the basics.

3) "The Java Tutorial" kept showing up when I was googl'ing for solutions. Lot's of good stuff there, but you still need to translate it into Netrexx. It has grown into my go-to site when I get confused on how to use a new class or component.

4) Javadoc is still beyond me. I tripped over it a few times but have not found a use for it with Netrexx. A primer there would be great.

Kenneth Klein



George Hovey [hidden email]
Sent by: [hidden email]

01/13/2012 01:58 PM

Please respond to
IBM Netrexx [hidden email]

To
IBM Netrexx [hidden email]
cc

Subject
Re: [Ibm-netrexx] java to rexx conversion works! - mostly...now        completely







Hi Kenneth,
This is wonderful news, and also has implications for our strategies in providing aid to newcomers like you.

You are the first I can remember who attacked the Java Tutorial head on (evidently with considerable success), and it could be very useful if you commented on your experiences while they are fresh in your mind.  Would you tell us anything you find noteworthy about the experience?  About your programming experience?  A few (random) questions that spring to my mind:
  • Can you make some sense of Java code, perhaps because you have a C/C++ background?
  • Did you start the Tutorials with basics (Java types, syntax, etc) or jump directly to the Swing Tutorial?
  • How would you rate the quality of the Java Tutorial?
  • Can you interpret (perhaps partially) a Javadoc?
Regards,
George

On Fri, Jan 13, 2012 at 11:57 AM, Alan Sampson <[hidden email]> wrote:


On 13 January 2012 07:11, Marc Remes <[hidden email]> wrote:
Glad that worked.
The inner class was not translated because it's an anonymous one. Difficult to trap these.
Also, true and false could be translated to 1 and 0 in NetRexx, but they are reserved words only for literal values. Might need some investigation to perform an automatic translation..

 
IMO it's better that true/false aren't translated to 1/0 as that would mean the initial type would be changed from boolean to int, which in turn may lead to undesirable side effects.  Results from tools like this always require a little clean-up work and any decent programmer's editor will make that a snap.  Having 98% to 99% of the conversion work done for you is a more than satisfactory outcome and saves a lot of the grunt work.

Alan.
 
--
Can't tweet, won't tweet!


_______________________________________________
Ibm-netrexx mailing list

[hidden email]
Online Archive :
http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works: java output from nrc

kenner
In reply to this post by Robert L Hamilton

C:\Documents and Settings\keklein\My Documents\REXX\NetRexx\FocusConceptsDemoProject\src\misc+  Mon
01/16/2012 15:28
 > type FocusConceptsDemo.java.keep
/* Generated from 'FocusConceptsDemo.nrx' 16 Jan 2012 15:28:08 [v3.01] *//* Options: Crossref Decima
l Java Logo Trace2 Verbose3 */package misc;

public class FocusConceptsDemo extends javax.swing.JPanel{private static final java.lang.String $0="
FocusConceptsDemo.nrx";

/* properties static */
protected static javax.swing.JFrame frame;

protected static netrexx.lang.Rexx properties;
protected static javax.swing.JTextField t1;
protected static javax.swing.JTextField t2;
protected static javax.swing.JTextField t3;
protected static javax.swing.JTextField t4;

protected static javax.swing.JButton b1;
protected static javax.swing.JButton b2;
protected static javax.swing.JButton b3;
protected static javax.swing.JButton b4;

protected static javax.swing.JTextArea text1;

public FocusConceptsDemo(){
super((java.awt.LayoutManager)(new java.awt.BorderLayout()));javax.swing.JPanel buttonPanel=null;jav
ax.swing.JPanel textAreaPanel=null;javax.swing.JPanel textFieldPanel=null;
b1=new javax.swing.JButton("JButton");
b4=new javax.swing.JButton("JButton");
b3=new javax.swing.JButton("JButton");
b2=new javax.swing.JButton("JButton");

buttonPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.GridLayout(1,1)));
buttonPanel.add((java.awt.Component)b1);
buttonPanel.add((java.awt.Component)b3);
buttonPanel.add((java.awt.Component)b2);
buttonPanel.add((java.awt.Component)b4);
text1=new javax.swing.JTextArea("JTextArea",15,40);

textAreaPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.BorderLayout()));
textAreaPanel.add((java.awt.Component)text1,(java.lang.Object)java.awt.BorderLayout.CENTER);
t1=new javax.swing.JTextField("JTextField");
t4=new javax.swing.JTextField("JTextField");
t3=new javax.swing.JTextField("JTextField");
t2=new javax.swing.JTextField("JTextField");

textFieldPanel=new javax.swing.JPanel((java.awt.LayoutManager)(new java.awt.GridLayout(1,1)));
textFieldPanel.add((java.awt.Component)t2);
textFieldPanel.add((java.awt.Component)t1);
textFieldPanel.add((java.awt.Component)t4);
textFieldPanel.add((java.awt.Component)t3);
add((java.awt.Component)buttonPanel,(java.lang.Object)java.awt.BorderLayout.PAGE_START);
add((java.awt.Component)textAreaPanel,(java.lang.Object)java.awt.BorderLayout.CENTER);
add((java.awt.Component)textFieldPanel,(java.lang.Object)java.awt.BorderLayout.PAGE_END);
setBorder(javax.swing.BorderFactory.createEmptyBorder(20,20,20,20));return;}

protected static void createAndShowGUI(){javax.swing.JComponent newContentPane=null;
frame=new javax.swing.JFrame("FocusConceptsDemo");
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);

newContentPane=(javax.swing.JComponent)(new misc.FocusConceptsDemo());
newContentPane.setOpaque(isTrue());
frame.setContentPane((java.awt.Container)newContentPane);
frame.pack();
frame.setVisible(isTrue());return;}

public static boolean isTrue(){
return (1==1);}

public static boolean isFalse(){
return new netrexx.lang.Rexx(isTrue()).OpNot(null);}

public static void main(java.lang.String args[]) throws java.lang.ClassNotFoundException,java.lang.I
nstantiationException,java.lang.IllegalAccessException,javax.swing.UnsupportedLookAndFeelException{

javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

javax.swing.UIManager.put((java.lang.Object)"swing.boldMetal",(java.lang.Object)java.lang.Boolean.FA
LSE);
javax.swing.SwingUtilities.invokeLater((java.lang.Runnable)(new misc.FocusConceptsDemo.RunnableImp()
));return;}

static class RunnableImp implements java.lang.Runnable{private final transient java.lang.String $0="
FocusConceptsDemo.nrx";
public void run(){
misc.FocusConceptsDemo.createAndShowGUI();
return;}public RunnableImp(){return;}}}
C:\Documents and Settings\keklein\My Documents\REXX\NetRexx\FocusConceptsDemoProject\src\misc+  Mon
01/16/2012 15:28



Kenneth Klein
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

Marc Remes-2
In reply to this post by kenner
On 01/16/2012 08:04 PM, [hidden email] wrote:
> Is the source to java2nrx written in netrexx? Is it available?
>

java2nrx is not written in NetRexx. I took the Java 1.5 parser and Abstract Syntax Tree
from http://code.google.com/p/javaparser and modified the DumpVisitor.java code to emit NetRexx instead of Java.
Spared me writing the whole AST parsing code.
Thus not written in NetRexx, and not easily translated because of the frequent use of type definitions, which do not
have an equivalent in NetRexx.

Source code available (easily imported as eclipse project) at
http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38

Feel free to contribute

Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

alansam
In reply to this post by kenner


On 16 January 2012 11:04, <[hidden email]> wrote:

Here is another sample from the java tutorial, converted to netrexx and working.

The conversion with java2nrx was fairly complete. A couple stray curly brackets survived. A couple properties keywords were superfluously created. The exception processing didn't compile so it's just commented out. And I still don't understand how the class "Runnable" works, but I just blindly followed Alan's tips like with ButtonDemo.


As has been mentioned earlier Runnable isn't a class it's an interface.  In Java (and NetRexx) parlance an interface describes the things a class should do, but doesn't implement them.  It's an OO inheritance trick to allow library objects to call your classes via predefined methods.  (The phrase "call back" and/or "user exit" spring to mind.)  When you create a class and implement an interface your class becomes a subclass of that interface.  In the example what you've done is create a class (FocusConceptsDemo.RunnableImp) that "is a" Runnable object when it comes into existence.  Java's threading model (which is used by Swing to do it's stuff) expects your "call back" to be an object of type Runnable so it can call the run method when it's ready.  You set the chain in motion from your main method by calling javax.swing.SwingUtilities.invokeLater and once Swing has all its ducks in a row it will call your run method to execute your code.  Easy really (ha!)

Alan.

PS  You can fix the compile problems in the exception handler section by giving each exception variable a unique name.  i.e.
       do 
           UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") 
        catch  ex1=UnsupportedLookAndFeelException 
           ex1.printStackTrace() 
        catch  ex2=IllegalAccessException 
           ex2.printStackTrace() 
        catch  ex3=InstantiationException 
           ex3.printStackTrace() 
        catch  ex4=ClassNotFoundException 
           ex4.printStackTrace() 
       end 


--
Can't tweet, won't tweet!

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

ThSITC
In reply to this post by Marc Remes-2
Good, and also funny point, Marc!

Hence, what is the problem with Java2Nrx ??

Thomas.
==============================================================
Am 16.01.2012 21:36, schrieb Marc Remes:

> On 01/16/2012 08:04 PM, [hidden email] wrote:
>> Is the source to java2nrx written in netrexx? Is it available?
>>
>
> java2nrx is not written in NetRexx. I took the Java 1.5 parser and
> Abstract Syntax Tree
> from http://code.google.com/p/javaparser and modified the
> DumpVisitor.java code to emit NetRexx instead of Java.
> Spared me writing the whole AST parsing code.
> Thus not written in NetRexx, and not easily translated because of the
> frequent use of type definitions, which do not have an equivalent in
> NetRexx.
>
> Source code available (easily imported as eclipse project) at
> http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38 
>
>
> Feel free to contribute
>
> Marc
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>
>


--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge
Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team
(www.netrexx.org)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

Tom Maynard
In reply to this post by Marc Remes-2
On 1/16/2012 2:36 PM, Marc Remes wrote:
>
> Source code available (easily imported as eclipse project) at
> http://kenai.com/nonav/projects/netrexx/sources/svn-contrib/show/tags/java2nrx-V1.0.0/java2nrx?rev=38 
>
>

I would dearly love to know how this is done.  I fired up Eclipse, I had
the above URL in my Paste buffer, but never did see any obvious way to
make the two communicate.

In explication: I did most of my work in the past in Netbeans, but have
now "migrated" to Eclipse ... where I remain a complete noob (outside of
some clearly spelled-out tasks).

Even if I never build Java2Nrx, I'd appreciate knowing how to achieve
this level of integration between SVN and Eclipse.

More details greatly appreciated!

Tom.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

Kermit Kiser
In reply to this post by alansam
Actually, Runnable is much simpler than that: It tells Java exactly one thing - This program has a method called "run". That's all it does. It is needed because Java looks for a method called "run" when it needs to start a new thread for a program.

In the simplest case (one extra thread), you don't even need to create another class to use it - just add "implements Runnable" to your main class statement and you can put the run method for your "subtask" thread right in with your other code. Here is a simple example of creating a thread for your program which does something once every second (increment a counter or update a progress display, etc):

--------------------------      NetRexx sample code ThreadDemo.nrx    -------------------------------

     class ThreadDemo implements Runnable

         properties static
            
            myinstance=ThreadDemo null
           
            savedthread=Thread null
        
         method main(is=String[]) static
            
             myinstance=ThreadDemo()                    --  Load this program (create instance)   
                      
            if savedthread=null then do                --    If subtask has not been started
                savedthread=Thread(myinstance)    --    create subtask to do something every second
                savedthread.start                                --    start the subtask thread
                end  
               
            say "get on with the main stuff "
            /* now get on with the program stuff   */
        
         method run
            
             loop forever

                Thread.sleep(1000)     --   sleep for 1 second
                          
                if savedthread=null then return
                   
                say "do something now"
                /*  do something every second here  */
               
                catch ie=InterruptedException
                    say ie.toString
                   
                end

--------------------------      End of NetRexx sample code:    -------------------------------

I use the above technique often for simple threading requirements. You can just set the "savedthread" variable to null at any time in your main program to cause the subtask thread to terminate.  (If you start the above sample with "nrc -run ThreadDemo", you can end it with CTRL-C )

-- Kermit


On 1/16/2012 12:47 PM, Alan Sampson wrote:


On 16 January 2012 11:04, <[hidden email]> wrote:

Here is another sample from the java tutorial, converted to netrexx and working.

The conversion with java2nrx was fairly complete. A couple stray curly brackets survived. A couple properties keywords were superfluously created. The exception processing didn't compile so it's just commented out. And I still don't understand how the class "Runnable" works, but I just blindly followed Alan's tips like with ButtonDemo.


As has been mentioned earlier Runnable isn't a class it's an interface.  In Java (and NetRexx) parlance an interface describes the things a class should do, but doesn't implement them.  It's an OO inheritance trick to allow library objects to call your classes via predefined methods.  (The phrase "call back" and/or "user exit" spring to mind.)  When you create a class and implement an interface your class becomes a subclass of that interface.  In the example what you've done is create a class (FocusConceptsDemo.RunnableImp) that "is a" Runnable object when it comes into existence.  Java's threading model (which is used by Swing to do it's stuff) expects your "call back" to be an object of type Runnable so it can call the run method when it's ready.  You set the chain in motion from your main method by calling javax.swing.SwingUtilities.invokeLater and once Swing has all its ducks in a row it will call your run method to execute your code.  Easy really (ha!)

Alan.

PS  You can fix the compile problems in the exception handler section by giving each exception variable a unique name.  i.e.
       do 
           UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") 
        catch  ex1=UnsupportedLookAndFeelException 
           ex1.printStackTrace() 
        catch  ex2=IllegalAccessException 
           ex2.printStackTrace() 
        catch  ex3=InstantiationException 
           ex3.printStackTrace() 
        catch  ex4=ClassNotFoundException 
           ex4.printStackTrace() 
       end 


--
Can't tweet, won't tweet!
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

kenner
In reply to this post by alansam

I still don't know why, but your code fixes do work. They compile at least. Don't know how I would test the exceptions. Now I am trying to understand how to control the order and selection of components eligible for focus. I want to skip some textboxes that are for display only. On to the KeyboardFocusManager!

Kenneth Klein
Systems Specialist
502-868-3644
859-750-5179 (Cell)
502-868-2298 (Fax)
[hidden email]



Alan Sampson <[hidden email]>
Sent by: [hidden email]

01/16/2012 04:09 PM

Please respond to
IBM Netrexx <[hidden email]>

To
IBM Netrexx <[hidden email]>
cc
Subject
Re: [Ibm-netrexx] java to rexx conversion works! - mostly...now        completely







On 16 January 2012 11:04, <kenneth.klein@...> wrote:

Here is another sample from the java tutorial, converted to netrexx and working.


The conversion with java2nrx was fairly complete. A couple stray curly brackets survived. A couple properties keywords were superfluously created. The exception processing didn't compile so it's just commented out. And I still don't understand how the class "Runnable" works, but I just blindly followed Alan's tips like with ButtonDemo.



As has been mentioned earlier Runnable isn't a class it's an interface.  In Java (and NetRexx) parlance an interface describes the things a class should do, but doesn't implement them.  It's an OO inheritance trick to allow library objects to call your classes via predefined methods.  (The phrase "call back" and/or "user exit" spring to mind.)  When you create a class and implement an interface your class becomes a subclass of that interface.  In the example what you've done is create a class (FocusConceptsDemo.RunnableImp) that "is a" Runnable object when it comes into existence.  Java's threading model (which is used by Swing to do it's stuff) expects your "call back" to be an object of type Runnable so it can call the run method when it's ready.  You set the chain in motion from your main method by calling javax.swing.SwingUtilities.invokeLater and once Swing has all its ducks in a row it will call your run method to execute your code.  Easy really (ha!)

Alan.

PS  You can fix the compile problems in the exception handler section by giving each exception variable a unique name.  i.e.
       do 
           UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel")
 
        catch  ex1=UnsupportedLookAndFeelException
 
           ex1.printStackTrace()
 
        catch  ex2=IllegalAccessException
 
           ex2.printStackTrace()
 
        catch  ex3=InstantiationException
 
           ex3.printStackTrace()
 
        catch  ex4=ClassNotFoundException
 
           ex4.printStackTrace()
 
       end
 


--
Can't tweet, won't tweet!
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: java to rexx conversion works! - mostly...now completely

alansam


On 17 January 2012 08:12, <[hidden email]> wrote:

I still don't know why, but your code fixes do work. They compile at least. Don't know how I would test the exceptions. Now I am trying to understand how to control the order and selection of components eligible for focus. I want to skip some textboxes that are for display only. On to the KeyboardFocusManager!

Kenneth Klein
Systems Specialist
<a href="tel:502-868-3644" value="+15028683644" target="_blank">502-868-3644
<a href="tel:859-750-5179" value="+18597505179" target="_blank">859-750-5179 (Cell)
<a href="tel:502-868-2298" value="+15028682298" target="_blank">502-868-2298 (Fax)
[hidden email]



The exception handling code wouldn't compile "out of the box" because the generated code was attempting to redefine the type of the ex variable. This would be OK in Java because the variables are treated as being in different scopes.  Because NetRexx is more dynamic and you don't need to predefine variables it was protecting you from clobbering something you'd already created.

The way I chose to solve the compilation was to create different variables for each exception case.  I could equally have predefined ex as an Exception and it would have compiled too.  I chose to do it the way I did for clarity only.  Here's a sample the alternative:

ex = Exception 
do
   UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") 
catch  ex=UnsupportedLookAndFeelException 
   ex.printStackTrace() 
catch  ex=IllegalAccessException 
   ex.printStackTrace() 
catch  ex=InstantiationException 
   ex.printStackTrace() 
catch  ex=ClassNotFoundException 
   ex.printStackTrace() 
end

If you want to test the exception handling code you could just stuff a signal clause anywhere after the do and the first catch clause.  The following program:

/* NetRexx */
options replace format comments java crossref symbols binary

import javax.swing.

ex = Exception
loop for 50
  do
  gronk()
  catch  ex = UnsupportedLookAndFeelException
    ex.printStackTrace(System.out)
  catch  ex = IllegalAccessException
    ex.printStackTrace(System.out)
  catch  ex = InstantiationException
    ex.printStackTrace(System.out)
  catch  ex = ClassNotFoundException
    ex.printStackTrace(System.out)
  end
end

say 'All done'

return

method gronk static signals UnsupportedLookAndFeelException, -
                            IllegalAccessException, -
                            InstantiationException, -
                            ClassNotFoundException
  rx = Random()
  ri = rx.nextInt(4)
  say '>>>' ri
  select case ri
    when 0 then
      signal IllegalAccessException()
    when 1 then
      signal UnsupportedLookAndFeelException("L&F")
    when 2 then
      signal InstantiationException()
    otherwise
      signal ClassNotFoundException()
    end

will drive the catch blocks.

Alan.

--
Can't tweet, won't tweet!

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

HOWTO connect to kenai SVN

Marc Remes-2
In reply to this post by Tom Maynard
As an example of the integration between SVN and eclipse,
here's the list of things to do to check out the java2nrx project from kenai SVN into eclipse.


Install eclipse 3.6 or 3.7, helios or indigo
   download Eclipse IDE for Java EE Developers, most complete

Install eclipse subversive plugin
   Help -> Install New Software
   Work with standard site : http://download.eclipse.org/releases/indigo or helios
   In Collaboration, select 'Subversive SVN Team provider'
   Press Next
   Select again and Next
   Accept terms and Finish
   Restart now after Installing Software
       
   Window -> Open Perspective -> Other -> SVN Repository Exploring
   From Subversive Connector Discovery, select SVN Kit 1.3.5 and Finish
   Install both proposed additional items, Subversive SVN Connectors and SVNKit, Next, Next
   Accept terms and Finish
   OK for unsigned content
   Restart now

Connect to kenai SVN repository
   Create SSH public/private key (or use existing)
   Login to http://kenai.com/ with $USERNAME and $PASSWORD
   My page -> Edit My Profile -> SSH keys tab
     Add Public Key

   In eclipse, from the SVN Repository perspective, right-click in the 'SVN Repositories' view
   New -> Repository Location
   URL svn+ssh://$[hidden email]/netrexx~svn-contrib
     where $USERNAME is your kenai username as found on View Public Profile
   Authentication credentials, $USERNAME and PASSWORD
   Check 'Save authentication'
   On the SSH Settings, check Private Key and browse to your Private key file,
   Enter passphrase if keypair is protected by passphrase
   Finish
   You will be prompted for local password vault to store the given credentials
   In the SVN Repositories, you should be able to browse the svn.kenai.com/netrexx~svn-contrib repository

Get the source, several ways..
   Window -> Open Perspective -> Java
   File -> New -> Java Project
   Project name: java2nrx
   Finish
   Right click on java2nrx directory
   Team -> Share Project -> SVN -> Next
   Use existing repository location -> Next -> Simple Mode
   URL: svn+ssh://$[hidden email]/netrexx~svn-contrib/java2nrx
   Finish
   .. already exist, wish to proceed -> Yes
   Voilà


Marc

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: HOWTO connect to kenai SVN

Tom Maynard
On 1/17/2012 3:51 PM, Marc Remes wrote:
> As an example of the integration between SVN and eclipse,
> here's the list of things to do to check out the java2nrx project from
> kenai SVN into eclipse.
>
>

Thank you, Marc, for the detailed, step-by-step procedure.  I'll be
working my way through these steps as soon as tomorrow.  I'll also make
an effort to preserve these instructions for future reference by others.

This is a great piece of knowledge, for anyone working with Eclipse and SVN.

Tom.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: HOWTO connect to kenai SVN

ThSITC
In reply to this post by Marc Remes-2
Thank you, Marc, for publishing this!
Thomas.
============================================================================
Am 17.01.2012 22:51, schrieb Marc Remes:

> As an example of the integration between SVN and eclipse,
> here's the list of things to do to check out the java2nrx project from
> kenai SVN into eclipse.
>
>
> Install eclipse 3.6 or 3.7, helios or indigo
>   download Eclipse IDE for Java EE Developers, most complete
>
> Install eclipse subversive plugin
>   Help -> Install New Software
>   Work with standard site :
> http://download.eclipse.org/releases/indigo or helios
>   In Collaboration, select 'Subversive SVN Team provider'
>   Press Next
>   Select again and Next
>   Accept terms and Finish
>   Restart now after Installing Software
>
>   Window -> Open Perspective -> Other -> SVN Repository Exploring
>   From Subversive Connector Discovery, select SVN Kit 1.3.5 and Finish
>   Install both proposed additional items, Subversive SVN Connectors
> and SVNKit, Next, Next
>   Accept terms and Finish
>   OK for unsigned content
>   Restart now
>
> Connect to kenai SVN repository
>   Create SSH public/private key (or use existing)
>   Login to http://kenai.com/ with $USERNAME and $PASSWORD
>   My page -> Edit My Profile -> SSH keys tab
>     Add Public Key
>
>   In eclipse, from the SVN Repository perspective, right-click in the
> 'SVN Repositories' view
>   New -> Repository Location
>   URL svn+ssh://$[hidden email]/netrexx~svn-contrib
>     where $USERNAME is your kenai username as found on View Public
> Profile
>   Authentication credentials, $USERNAME and PASSWORD
>   Check 'Save authentication'
>   On the SSH Settings, check Private Key and browse to your Private
> key file,
>   Enter passphrase if keypair is protected by passphrase
>   Finish
>   You will be prompted for local password vault to store the given
> credentials
>   In the SVN Repositories, you should be able to browse the
> svn.kenai.com/netrexx~svn-contrib repository
>
> Get the source, several ways..
>   Window -> Open Perspective -> Java
>   File -> New -> Java Project
>   Project name: java2nrx
>   Finish
>   Right click on java2nrx directory
>   Team -> Share Project -> SVN -> Next
>   Use existing repository location -> Next -> Simple Mode
>   URL: svn+ssh://$[hidden email]/netrexx~svn-contrib/java2nrx
>   Finish
>   .. already exist, wish to proceed -> Yes
>   Voilà
>
>
> Marc
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
>
>


--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge
Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team
(www.netrexx.org)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
12