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


Dave Woodman

I have the horrible thought that this might not make it through the list software intact, so I have BCC’ed René and KP…

A Simplistic Example of NetRexx/Eclipse/Swing/WindowBuilder


WindowBuilder and NetRexx plugin installed in Eclipse.

Some experience of mixing Java and NetRexx within Eclipse.


Create the Project:-

Open a new Java project (File->New->Java Project)

Within the project create a new package (WindowBuilder prefers it that way)


Create GUI:-



Fill out the Wizard…


And click Finish…

Click “Design”

From the Palette select and drop the following onto the canvas:-

·         GridBagLayout

·         JLabel

·         JTextField

·         JButton

·         JTextArea

Right-click on the button, Add Event Handler->Action->actionPerformed

These components can be customised to suit in the properties pane(s), but, for now we will leave them as they are.

If you were not taken to the source view then click on the “Source” button next to “Design.” You are now presented with the source to create your basic GUI.

Add a NetRexx source file – for the sake of the example call it “bridge.nrx”


/* A "bridge" for the WindowBuilder example */


options replace


package org.netrexx


import javax.swing

import java.awt


class bridge


        properties private

                textBox = JTextField

                outBox = JTextArea


        method bridge(args = String[])


                /* Do all of your NetRexx initialisation here... */


        method addSrc(in = JTextField) -- Could use the indirect property support for these...

                textBox = in



        method addDest(out = JTextArea)

                outBox = out



        method doIt

                str = textBox.getText()



We will connect this to the Swing GUI, and when the button is pressed text will be taken from the text field and added to the text area.

To connect, modify the swing generated code as such

package org.netrexx;


import java.awt.EventQueue;



public class Demo {


        private JFrame frame;

        private JTextField textField;

        private static bridge nrBit; /* nrBit - the NetRexx bit */



        * Launch the application.


        public static void main(String[] args) {

                nrBit = new bridge(args); /* Setup the NetRexx side of things - note that the GUI is NOT READY!!! */

                EventQueue.invokeLater(new Runnable() {

                        public void run() {

                                try {

                                        Demo window = new Demo();


                                } catch (Exception e) {








        * Create the application.


        public Demo() {





        * Initialize the contents of the frame.


        private void initialize() {

                frame = new JFrame();

                frame.setBounds(100, 100, 450, 300);


                GridBagLayout gridBagLayout = new GridBagLayout();

                gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};

                gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};

                gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};

                gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};



                JLabel lblNewLabel = new JLabel("New label");

                GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();

                gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);

                gbc_lblNewLabel.gridx = 3;

                gbc_lblNewLabel.gridy = 0;

                frame.getContentPane().add(lblNewLabel, gbc_lblNewLabel);


                textField = new JTextField();

                GridBagConstraints gbc_textField = new GridBagConstraints();

                gbc_textField.insets = new Insets(0, 0, 5, 0);

                gbc_textField.fill = GridBagConstraints.HORIZONTAL;

                gbc_textField.gridx = 3;

                gbc_textField.gridy = 2;

                frame.getContentPane().add(textField, gbc_textField);



                nrBit.addSrc(textField); /* Add the souce field to the bridge */


                JButton btnNewButton = new JButton("New button");

                btnNewButton.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent arg0) {

                                nrBit.doIt(); /*Add the action call */



                GridBagConstraints gbc_btnNewButton = new GridBagConstraints();

                gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);

                gbc_btnNewButton.gridx = 3;

                gbc_btnNewButton.gridy = 4;

                frame.getContentPane().add(btnNewButton, gbc_btnNewButton);


                JTextArea textArea = new JTextArea();

                GridBagConstraints gbc_textArea = new GridBagConstraints();

                gbc_textArea.fill = GridBagConstraints.BOTH;

                gbc_textArea.gridx = 3;

                gbc_textArea.gridy = 6;

                frame.getContentPane().add(textArea, gbc_textArea);


                nrBit.addDest(textArea); /* Add the output pane... */





This can be invoked via “Run As->Java Application”



Ibm-netrexx mailing list
[hidden email]
Online Archive :

Reply | Threaded
Open this post in threaded view

Re: NetRexx/Eclipse/Swing/WindowBuilder

Could we have a Wiki page or something else where these things could be posted, probably as a subpage of the original Netrexx Homepage?

Exactly that is that kind of information I am looking for.
Reply | Threaded
Open this post in threaded view

Re: NetRexx/Eclipse/Swing/WindowBuilder

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
        bridge cannot be resolved to a type
        bridge cannot be resolved to a type
        JFrame cannot be resolved to a type

        at org.netrexx.Demo.main(

When I cut and paste the nrx and java code listed above into eclipse, I get the above error messages.