Learning Java Objects

classic Classic list List threaded Threaded
58 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

David Requena
Maybe...

I just found Dion on Facebook and set a message/proposal to him :-)

No answer but then it was 10 minutes ago!

---
Saludos / Kind regards.
David Requena

El 05/10/2010 17:45, Fernando Cassia escribió:
On Tue, Oct 5, 2010 at 12:20 PM, David Requena [hidden email] wrote:
Once upon a time Dion Gillard had NetRexx adapted javadocs for the java API
at his NetRexx FAC website. That site has been long dead now and its archive
at wayback machine is incomplete.
Is there any chance to recover this?

FC
_______________________________________________
Ibm-netrexx mailing list
[hidden email]


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

George Hovey-2
In reply to this post by FreeFall
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Quique Britto
I ended up purchasing a Java Book as I find the Javadoc too much for my eyes.
I have started writing a tutorial for writing Netrexx programs using Java Swing, it's basically a shortcut for people who wish to use Swing and Netrexx.

http://www.esimplesoft.es/


Quique




On 5 October 2010 17:53, George Hovey <[hidden email]> wrote:
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Learning Java Objects

Mike Cowlishaw
In reply to this post by David Requena
I just found Dion on Facebook and set a message/proposal to him :-)

No answer but then it was 10 minutes ago!

Don't hold your breath.  Sadly, Dion died a couple of years ago.   He is much missed; he was a really super guy.
 
Mike 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Fernando Cassia-2
On Tue, Oct 5, 2010 at 1:26 PM, Mike Cowlishaw <[hidden email]> wrote:
> I just found Dion on Facebook and set a message/proposal to him :-)
>
> No answer but then it was 10 minutes ago!
>
> Don't hold your breath.  Sadly, Dion died a couple of years ago.   He is
> much missed; he was a really super guy.

A reminder to publish everything, and create as many mirrors as possible. :-/
The shutdown of Geocities took down several useful utilities with it.

And God, Archive.org seems to miss or lose the best stuff, always.
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Fernando Cassia-2
In reply to this post by Quique Britto
On Tue, Oct 5, 2010 at 1:19 PM, Quique Britto <[hidden email]> wrote:
> I ended up purchasing a Java Book as I find the Javadoc too much for my
> eyes.
> I have started writing a tutorial for writing Netrexx programs using Java
> Swing, it's basically a shortcut for people who wish to use Swing and
> Netrexx.
>
> http://www.esimplesoft.es/

Quique,

Very nice, but I´d add a link at the end of each section, linking to the next.
That´d make wget -m -np -k -c http://url much easier :)

FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Kermit Kiser
In reply to this post by Quique Britto
Quique ;

Your tutorial looks like a good starting place!

I noticed that the info about jEdit is a little out of date. There are now two NetRexx plugins for jEdit - NetRexxDE which replaces the old jEdit 4.2 plugin "NetRexxJe" for the NetRexx compiler and the new NetRexxScript plugin for the NetRexx interpreter which runs scripts. Both plugins work with the current jEdit version (4.3). NetRexxScript installs via the plugin manager and NetRexxDE can be found here:

http://kenai.com/projects/netrexx-misc/pages/NetRexxDE

-- Kermit



On 10/5/2010 9:19 AM, Quique Britto wrote:
I ended up purchasing a Java Book as I find the Javadoc too much for my eyes.
I have started writing a tutorial for writing Netrexx programs using Java Swing, it's basically a shortcut for people who wish to use Swing and Netrexx.

http://www.esimplesoft.es/


Quique




On 5 October 2010 17:53, George Hovey <[hidden email]> wrote:
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects (The GUI affair)

Robert L Hamilton
In reply to this post by David Requena
This code gives ( in jEdit)

[C:\Program Files\jEdit\guisample.nrx 35 12 4]  Error: Method signature duplicates another method: 'main(String[])'

bobh

On Tue, Oct 5, 2010 at 9:31 AM, David Requena <[hidden email]> wrote:


El 05/10/2010 2:22, George Hovey escribió:
Hope David Requena weighs in on this - I think he is pretty GUI aware.

While that might be true, I've to say it'd be more out of sheer stubbornness in tackling hard challenges than out of any practical matter :-)
Non-trivial GUIs are not easy to make from NetRexx nor from java itself.

FWIW the only reasonable way to do this is by taking advantage of the fact that java classes and NetRexx's own are the very same thing.
So my advice is: do use NetBeans' wonderful point & click tools to make your GUI, compile it, and then drive it from your NetRexx program.
Use your time to do more interesting things with NetRexx :-)
I think René is also using this approach in his projects. See http://www.rexxla.org/events/2004/renej.pdf

In general GUI programming is a hard domain in itself. It is in java, it is in windows, it was in OS/2, Linux,... you get the picture. That's why tools such as the ones mentioned by Fernando exist. IMHO GUI programming makes no good introduction to any language and/or platform.

In the case of java platform the issue is exacerbated by the fact that its GUIs must work consistently across many underlying platforms with very different graphics systems, usability conventions, etc. In short, java's GUI framework (SWING) must be pretty generic.

Java GUI programming is not only about object oriented programming. You must also have a good grasp about event driven programming, swing's particular threading model and and the model-view-controller design pattern. And that is just a start!

Lets see these in a bit of detail. Lets also use Kermit's sample for illustration purposes:

----------------------------------  NetRexx GUI sample code  ---------------------------------------
import javax.swing.

class guisample implements ActionListener     --    ActionListener interface lets the GUI objects talk to the program code
  
    properties static
        frame=JFrame                                      --    holder for a GUI window
  
    method main(sa=String[]) static

        frame=JFrame("Sample GUI window")                 --    create a GUI window frame
        frame.setSize(400,100)                            --    give the window some space on the screen
        panel=JPanel()                                    --    create a panel to hold some GUI objects
        frame.add(panel)                                  --    put the panel in the window frame
        textfield=JTextField("Some default text here")    --    create a spot for some text
        panel.add(textfield)                              --    add the text field to the panel
        button=JButton("OK")                              --    create a button to click
      
        button.addActionListener(guisample())             --    attach some code (an instance of this class) to watch the button
      
        panel.add(button)                                 --    put the button in the panel
        frame.show                                        --    display the GUI window on the screen
      
        loop while frame\=null;end                        --    wait for the GUI window to do something
      
        say textfield.getText                             --    show the text field contents
      
    method actionPerformed(e=ActionEvent)                 --    this is the code that listens to the button
        frame.dispose                                     --    clear the GUI window frame from screen and memory
        frame=null                                        --    erase the pointer to stop the main program
-------------------------------------------------------------------------------------------------------------

- Event driven programming.
OK, your main(args=String[]) method gets called, some window gets painted on the screen and nothing else happens.
In particular the flow of your program falls down the end of the function but your app does not terminate! It just sits there waiting for you to click some button, menu, etc.
When you do so that actionPerformed(e=ActionEvent) function gets "magically" called. Who calls it? I'll be answering these questions in the threading model section.
The point here is that under event driven programming you don't control your programs flow. Instead you create some graphics objects and let the system paint them on the screen. When some object is to be active, you register some listener object which will be called by the system behind the scenes when needed. That is what
button.addActionListener() is doing in Kermit's code.
If you want your app to terminate, you need to do so explicity like
actionPerformed(e=ActionEvent) above.

Nothing of this is very OO. It is in fact very similar to how you go about in in, say, Windows GUI programming.

- Threading model.
Why doesn't the program terminate when flow reaches the end of main? How actionPerformed() gets called?
Whenever you create some GUI object the runtime starts in the background a so-called Event Dispatch Thread (EDT) which will keep running until you somehow tell it to quit. This is the thread which watches Kermit's button and calls actionPerformed() when needed. In this program calling frame.dispose causes all childs added to it to also be disposed. As there are no remaining GUI objects the EDT shuts itself down and the app finally terminates.

Now look at the loop in red above. This is not needed at all; the program works exactly the same without it. It is in fact an error; it will just cause one of your CPU cores to go 100% CPU usage for just nothing. IOW, you don't need to keep your execution thread alive, the EDT will prevent the program to terminate.

Another thing to be aware of is that most GUI components are not thread safe so they should only be modified from the EDT. But you don't want to call any long running function from the EDT as your application would freeze until it were finished running. This leads to scenarios involving several threads, calls to SwingUtilities.invoqueLatter(someRunnable), etc. ad nauseam....

- MVC pattern
Most non-trivial swing components rely heavily on the model-view-controller design pattern (often with view and controller coerced into a single class).
This way, I can imagine George having a bad time maintaining his table data in a DefaultTableModel while manipulating the table appearance and behaviour in a JTable. BTW, DefaultTableModel is a pretty lame implementation which you should subclass to get some useful functionality.

MVC has many advantages but being easy to grasp is not one of them. :-(


Conclusion:

All in all, doing GUI's "by hand" does not pay off. It's easy to build some trivial useless GUI but anything else is just wasted time. There are very good graphic tools around to do this stuff. These will give you much better code anyway.

Even a simple example as Kermit's contains several problems (most of which I simply glossed over).
Here is a more correct version (mind you I cannot even be sure it's totally correct!):

import javax.swing.

class guisample public implements ActionListener
  
    properties inheritable static
        frame = JFrame
        textfield = JTextField
  
    method main(sa=String[]) static
        -- build a gui and die..
        guisample()
      
    method guisample
        -- GUI objects must be instantiated from EDT so
        -- tell it to do so
        SwingUtilities.InvokeLater(this.guiBuilder())
               
    method actionPerformed(e=ActionEvent)
        -- safe here as event handling code is called from EDT
        say textfield.getText
        frame.dispose
        frame=null
   
       
class guisample.guiBuilder dependent implements Runnable
   
    -- SwingUtilities.InvokeLater requires a Runnable so we need
    -- a separate class :-(
   
    method run
        parent.frame=JFrame("Sample GUI window")
        parent.frame.setSize(400,100)
        panel=JPanel()
        parent.frame.add(panel)
        parent.textfield=JTextField("Some default text here")
        panel.add(parent.textfield)
        button=JButton("OK")
        button.addActionListener(parent)
        panel.add(button)
        parent.frame.setVisible(1)

---
Saludos / Kind regards.
David Requena


_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Quique Britto
In reply to this post by Fernando Cassia-2
noted, will do asap.


On 5 October 2010 18:40, Fernando Cassia <[hidden email]> wrote:
On Tue, Oct 5, 2010 at 1:19 PM, Quique Britto <[hidden email]> wrote:
> I ended up purchasing a Java Book as I find the Javadoc too much for my
> eyes.
> I have started writing a tutorial for writing Netrexx programs using Java
> Swing, it's basically a shortcut for people who wish to use Swing and
> Netrexx.
>
> http://www.esimplesoft.es/

Quique,

Very nice, but I´d add a link at the end of each section, linking to the next.
That´d make wget -m -np -k -c http://url much easier :)

FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Quique Britto
In reply to this post by Kermit Kiser
I use eCS (OS/2) which Java is currently at 1.41 level only therefore can only use the tools what currently work.
luckily enough Java Developers Kit is being updated to current level and should be available to us eCS users before the end of the year.

will update jEdit section there.

Quique



On 5 October 2010 19:09, Kermit Kiser <[hidden email]> wrote:
Quique ;

Your tutorial looks like a good starting place!

I noticed that the info about jEdit is a little out of date. There are now two NetRexx plugins for jEdit - NetRexxDE which replaces the old jEdit 4.2 plugin "NetRexxJe" for the NetRexx compiler and the new NetRexxScript plugin for the NetRexx interpreter which runs scripts. Both plugins work with the current jEdit version (4.3). NetRexxScript installs via the plugin manager and NetRexxDE can be found here:

http://kenai.com/projects/netrexx-misc/pages/NetRexxDE

-- Kermit




On 10/5/2010 9:19 AM, Quique Britto wrote:
I ended up purchasing a Java Book as I find the Javadoc too much for my eyes.
I have started writing a tutorial for writing Netrexx programs using Java Swing, it's basically a shortcut for people who wish to use Swing and Netrexx.

http://www.esimplesoft.es/


Quique




On 5 October 2010 17:53, George Hovey <[hidden email]> wrote:
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

David Requena
In reply to this post by George Hovey-2

Of course I would contribute to such an effort.
There have been a couple tutorials around which I'm sure contain interesting material. Kermit's NetrexxScript comes with one of these bundled.
---
Saludos / Kind regards.
David Requena

El 05/10/2010 17:53, George Hovey escribió:
Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

David Requena
In reply to this post by Quique Britto
Nice work Quique!

I knew that websit but hadn't noticed it was yours :-)
---
Saludos / Kind regards.
David Requena

El 05/10/2010 18:19, Quique Britto escribió:
I ended up purchasing a Java Book as I find the Javadoc too much for my eyes.
I have started writing a tutorial for writing Netrexx programs using Java Swing, it's basically a shortcut for people who wish to use Swing and Netrexx.

http://www.esimplesoft.es/


Quique




On 5 October 2010 17:53, George Hovey <[hidden email]> wrote:
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

David Requena
In reply to this post by Mike Cowlishaw

Oh, such sad news...
I never met him either in person nor electronically but every reference I've got from him has been one of a great person.

For me his work was like a mirage of a time when NetRexx actually had a community with people which actually contributed their work to the better of all.
A time when I wasn't involved in anything NetRexx related yet.

Maybe somehow recovering part of his previous work and making it public again could be a kind of homage to him.
Of course, I'm in no position for such an endeavour.
---
Saludos / Kind regards.
David Requena

El 05/10/2010 18:26, Mike Cowlishaw escribió:
I just found Dion on Facebook and set a message/proposal to him :-)

No answer but then it was 10 minutes ago!

Don't hold your breath.  Sadly, Dion died a couple of years ago.   He is much missed; he was a really super guy.
 
Mike 
_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Robert L Hamilton
In reply to this post by David Requena
I don't know if I can help; but I have time on my hands to try.

Bob H

On Tue, Oct 5, 2010 at 4:55 PM, David Requena <[hidden email]> wrote:
Nice work Quique!

I knew that websit but hadn't noticed it was yours :-)
---
Saludos / Kind regards.
David Requena

El 05/10/2010 18:19, Quique Britto escribió:
I ended up purchasing a Java Book as I find the Javadoc too much for my eyes.
I have started writing a tutorial for writing Netrexx programs using Java Swing, it's basically a shortcut for people who wish to use Swing and Netrexx.

http://www.esimplesoft.es/


Quique




On 5 October 2010 17:53, George Hovey <[hidden email]> wrote:
Connor, David

David wrote:
When it comes to the java library, I think it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages). Then, when you need something in particular,  you just look it up and use it. I don't think anyone is going to hold the whole 2700+ classes thing in his head!

Connor wrote:
Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs?
-------------------------------------------------------------
This seems to me to focus on a core issue in making NetRexx new user-friendly.  Connor, trying to get his arms around Java, wants to know "how to use the more useful objects".  David replies, correctly, that " it's just a matter of overseeing what is available in there and how is it broken into different "functional domains" (packages)".  I suspect that Connor doesn't find this answer totally satisfactory.

The answer, briefly, is that we can't tell you what are the more useful objects, because only you know what interests you.  You don't need to read Java code.  You do need to explore the Java API by reading it's Javadoc documentation.  You don't use the Javadoc program itself, you just look at its HTML output files describing the API,  which can be downloaded from Sun/Oracle, with your browser.  This requires that you know how the find you way around the browser display to locate packages, classes, properties and methods.  You also have to understand the nature of Java's data types, both native and Object.  Then you are ready to invoke any Java class that strikes your fancy from NetRexx and without the use of Java code (you are using only NetRexx objects which are, with a few weasel words, identical to Java's).

Connor wrote: In short, is there a NetRexx Cookbook?

No, but there must be if we are to succeed (although the old IBM Red Book could be so described).  The information in the previous paragraph should be there but in much expanded form, with screen shots etc.  If you would be willing to contribute time to advancing this cause, I am available, and I think others, certainly David, will contribute.  I propose that we find out what is require to "bootstrap" you into Java API awareness by doing it step by step.  This will give us the information to produce a fair stab at the article "Using the Java Class Library in NetRexx" in "The NetRexx Cookbook".  I would be glad to act as recording secretary in collecting materials.  I also have Adobe Acrobat (writer) to produce a PDF.
We might start a new thread and ask people to use it solely for contributions to this experiment.

What do you think?

On Tue, Oct 5, 2010 at 8:23 AM, Connor Birch <[hidden email]> wrote:

On 5 Oct 2010, at 12:47, David Requena wrote:

IMO the stumbling block when coming to object oriented programming from an structured or procedural background is precisely the mind shift required by OO. You need to start thinking in objects as opposed procedures, subroutines, functions, data structures an so. 

I'm told this can be difficult to achieve. In all honesty it wasn't for me. OO is all about a few very simple principles with fancy names specially designed to scare outsiders (polymorphism, encapsulation, information hiding, inheritance, abstraction, message passing, decoupling, ...).
Believe me, this is very simple stuff. If your ever implemented and ADT in your procedural language of choice, you already have done 80% of the way!

Okay, I don't have a problem wit the concepts, most of what you mentioned ought to be familiar stuff to anyone who has written well structured code.   The only concept listed above that goes beyond 'normal' programming is inheritance.   I once took a course in Objective C; learning the concepts was no problem.   Making sense of the programming language was another issue entirely.  

In short, don't bother to "learn java's objects" (or C++', Smalltalk's, Python's, or even NetRexx'). Just pick some tutorial on object orientation which plainly explains these OO concepts and you'll be prepared to tackle any OO language. At the end of the day it's just a matter of assessing how these languages' syntaxes support the basic OO concepts. Most languages do a pretty poor job out of this task but that is not the case of NetRexx :-)

So its not an OO tutorial I need.

Also NetRexx in particular allows for a gentle two phased approach to OO programming in which you don't do any OO coding but you just *USE* existing objects. That is NetRexx' scripting mode.

/* An script using objects */

Say "This particular instant in time is:" Date().toString

/* done! */


Yep! We didn't bother with classes, methods, properties or anything OO here. Just took advantage of a given Date object which offers a toString "function" returning a nicely formatted string.
As a matter of fact you can leverage the whole java library (and literally thousands of freely available OSS ones) in this fashion; just by putting your run of the mill first argument to the front, putting in a dot and then the function (method!) at the end. Not bad!

Yep, you are right, getting to grips with existing java objects is a great starting point, especially where I'm not intending to leverage the OO aspect, and just want to write portable programs.    So just how do I do that?   Where/which is the guide that tells me how to use the more useful objects in a NetRexx centred way, that doesn't expect me to read Java programs? 

In short, is there a NetRexx Cookbook?

Connor.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]



_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]




_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

Fernando Cassia-2
In reply to this post by Quique Britto
On Tue, Oct 5, 2010 at 6:46 PM, Quique Britto <[hidden email]> wrote:
> I use eCS (OS/2) which Java is currently at 1.41 level only therefore can
> only use the tools what currently work.
> luckily enough Java Developers Kit is being updated to current level and
> should be available to us eCS users before the end of the year.

You mean that someone is porting the current Java 6uNN to OS/2?? Using
OpenJDK I guess?. And who is doing this? MenSys? or Paul Smedley using
emx tools?.

Thanks.
FC
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects

David Requena
In reply to this post by Fernando Cassia-2

Too true, sadly.
---
Saludos / Kind regards.
David Requena

El 05/10/2010 18:35, Fernando Cassia escribió:
On Tue, Oct 5, 2010 at 1:26 PM, Mike Cowlishaw [hidden email] wrote:
I just found Dion on Facebook and set a message/proposal to him :-)

No answer but then it was 10 minutes ago!

Don't hold your breath.  Sadly, Dion died a couple of years ago.   He is
much missed; he was a really super guy.
A reminder to publish everything, and create as many mirrors as possible. :-/
The shutdown of Geocities took down several useful utilities with it.

And God, Archive.org seems to miss or lose the best stuff, always.
FC

_______________________________________________
Ibm-netrexx mailing list
[hidden email]


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects (The GUI affair)

David Requena
In reply to this post by Robert L Hamilton
Which code you mean? Kermit's or mine?
I tested both under both NetrexxScript and NetRexxDE and everything worked.
Maybe we have some different option set at NetrexxScript plugin options?
---
Saludos / Kind regards.
David Requena

El 05/10/2010 21:54, Robert Hamilton escribió:
his code gives ( in jEdit)

[C:\Program Files\jEdit\guisample.nrx 35 12 4]  Error: Method signature duplicates another method: 'main(String[])'


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects (The GUI affair)

Kermit Kiser
If he is running my code under NetRexxScript with the "prefix" option on, he needs to make sure that the "import" statement is the first program line and that the file name matches the class name.

BTW: I had to laugh at your comment about the "loop" in my code - I was thinking this when I posted it: "No real program would have a loop like that but if I remove it the code might be more difficult for a newbie to understand or try."  My goal was to simplify the GUI concepts as much as possible with the minimum OO and MVC stuff. The loop is actually there to force NetRexxScript to intercept the "say" output if you run it there.

-- Kermit


On 10/5/2010 3:32 PM, David Requena wrote:
Which code you mean? Kermit's or mine?
I tested both under both NetrexxScript and NetRexxDE and everything worked.
Maybe we have some different option set at NetrexxScript plugin options?
---
Saludos / Kind regards.
David Requena

El 05/10/2010 21:54, Robert Hamilton escribió:
his code gives ( in jEdit)

[C:\Program Files\jEdit\guisample.nrx 35 12 4]  Error: Method signature duplicates another method: 'main(String[])'


_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects (The GUI affair)

David Requena

---
Saludos / Kind regards.
David Requena

El 06/10/2010 3:01, Kermit Kiser escribió:
If he is running my code under NetRexxScript with the "prefix" option on, he needs to make sure that the "import" statement is the first program line and that the file name matches the class name.

Ah, thought so but I keep forgetting the details. Maybe it would be a good idea to rename that option to "Enable jEdit macro development" or something similar.


BTW: I had to laugh at your comment about the "loop" in my code - I was thinking this when I posted it: "No real program would have a loop like that

Yeah is, the kind of code which tends to hurt your eyes when you read it :-D
I'm no expert in such kind of code but I seem to remember that the semicolon is not an instruction in NetRexx. So an actual "nop" would be needed in the body of the loop?

but if I remove it the code might be more difficult for a newbie to understand or try." My goal was to simplify the GUI concepts as much as possible with the minimum OO and MVC stuff.

I see your point. That is part of what I tried to convey in that email. You cannot really explain the GUI stuff in simple terms. Without getting into things like the event dispatch thread for instance.

  The loop is actually there to force NetRexxScript to intercept the "say" output if you run it there.


Which in turn I'm not sure from the top of my mind is a safe thing to do at that point. After all it's reading the contents of a JTextField whose containing component has not only been disposed but also been given to the garbage collector for shredding.

Still... that might be OK!
There are too many subtleties to take into account...

-- Kermit


On 10/5/2010 3:32 PM, David Requena wrote:
Which code you mean? Kermit's or mine?
I tested both under both NetrexxScript and NetRexxDE and everything worked.
Maybe we have some different option set at NetrexxScript plugin options?
---
Saludos / Kind regards.
David Requena

El 05/10/2010 21:54, Robert Hamilton escribió:
his code gives ( in jEdit)

[C:\Program Files\jEdit\guisample.nrx 35 12 4]  Error: Method signature duplicates another method: 'main(String[])'


_______________________________________________ Ibm-netrexx mailing list [hidden email]
_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Learning Java Objects (The GUI affair)

Robert L Hamilton

Here is the code I'm trying to run in jEdit;  I don't find a 'prefix' setting.  email gives some spurious line breaks.

bobh




--  --------------------------------  NetRexx GUI sample code  ---------------------------------------
import javax.swing.

  class guisample implements ActionListener     --    ActionListener interface lets the GUI objects talk to the program code
 
    properties static
        frame=JFrame                           --    holder for a GUI window
 
    method main(sa=String[]) static

        frame=JFrame("Sample GUI window")                 --    create a GUI window frame
        frame.setSize(400,100)                            --    give the window some space on the screen
        panel=JPanel()                                    --    create a panel to hold some GUI objects
        frame.add(panel)                                  --    put the panel in the window frame
        textfield=JTextField("Some default text here")    --    create a spot for some text
        panel.add(textfield)                              --    add the text field to the panel
        button=JButton("OK")                              --    create a button to click
     
        button.addActionListener(guisample())             --    attach some code (an instance of this class) to watch the button
     
        panel.add(button)                                 --    put the button in the panel
        frame.show                                        --    display the GUI window on the screen
     
        loop while frame\=null;end                        --    wait for the GUI window to do something
     
        say textfield.getText                             --    show the text field contents
     
    method actionPerformed(e=ActionEvent)                 --    this is the code that listens to the button
        frame.dispose                                     --    clear the GUI window frame from screen and memory
        frame=null                                        --    erase the pointer to stop the main program

/*  some notes removed here  */


import javax.swing.

 class guisample public implements ActionListener
 
    properties inheritable static
        frame = JFrame
        textfield = JTextField
 
    method main(sa=String[]) static
        -- build a gui and die..
        guisample()
     
    method guisample
        -- GUI objects must be instantiated from EDT so
        -- tell it to do so
        SwingUtilities.InvokeLater(this.guiBuilder())
              
    method actionPerformed(e=ActionEvent)
        -- safe here as event handling code is called from EDT
        say textfield.getText
        frame.dispose
        frame=null
  
      
class guisample.guiBuilder dependent implements Runnable
  
    -- SwingUtilities.InvokeLater requires a Runnable so we need
    -- a separate class :-(
  
    method run
        parent.frame=JFrame("Sample GUI window")
        parent.frame.setSize(400,100)
        panel=JPanel()
        parent.frame.add(panel)
        parent.textfield=JTextField("Some default text here")
        panel.add(parent.textfield)
        button=JButton("OK")
        button.addActionListener(parent)
        panel.add(button)
        parent.frame.setVisible(1)

-- Saludos / Kind regards. David Requena

 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

123