home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / nrxsamp.zip / DLR.NRX next >
Text File  |  1997-08-13  |  2KB  |  66 lines

  1. /*
  2.  * DLR.nrx  --  GUI implementation of user registry
  3.  */
  4.  
  5.  
  6. class DLR extends Frame              -- inherit from & extend the Frame class
  7.  
  8. properties private                   -- several methods in this class use
  9.   bstop = Button("  Stop  ")         --   the buttons and text fields
  10.   bhowdy = Button("  Say Howdy  ")
  11.  
  12. method main(s=String[]) static       -- static call of self
  13.   DLR("DLR" Rexx(s))
  14.  
  15. method dlr(s=String)                 -- constructor
  16.   super(s)                           -- Frame needs to know title
  17.   setLayout(BorderLayout())          -- our frame's layout
  18.   setBackground(Color.blue)
  19.   setForeground(Color.cyan)
  20.  
  21.   banner = Label("   My First NetREXX GUI Program   ", Label.CENTER)
  22.   add("North", banner)               -- position our "banner"
  23.  
  24.   p1 = Panel()                       -- a different layout for the buttons
  25.   p1.add(bstop)                      -- add the buttons to the panel
  26.   p1.add(bhowdy)
  27.   add("South", p1)                   -- add the panel to the frame
  28.  
  29.   p2 = Panel()                       -- a container for the "center" stuff
  30.   p2.setLayout(BorderLayout())       -- but we want some control
  31.   p2.setBackground(Color.blue)       -- set fg and bg colors for this area
  32.   p2.setForeground(Color.orange)
  33.   ulabel = Label("My Howdy Panel", Label.CENTER)   -- some label text
  34.   p2.add("Center", ulabel)           -- populate this piece
  35.   add("Center", p2)                  -- place the panel within the frame
  36.  
  37.   w = 350                            -- calculations to control the position
  38.   h = 200                            --  of the frame when it appears on the
  39.   screen = Toolkit.getDefaultToolkit.getScreenSize    -- display
  40.   reshape((screen.width-w)%2, (screen.height-h)%2, w, h)
  41.  
  42.   this.pack                          -- pack up the contents of the frame
  43.   this.show                          --  and display it
  44.  
  45.  
  46. /* Handle an action (button press) */
  47.  
  48. method action(e=Event, o=Object) returns boolean
  49.   select
  50.      when e.target = bstop  then exit -- if Stop button, bye-bye
  51.      when e.target = bhowdy then do   -- if Howdy button,
  52.         return 1
  53.         end
  54.      otherwise return super.action(e, o)     -- some other action we don't handle
  55.      end
  56.  
  57. /* Handle an event (window close) */
  58. method handleEvent(e=Event) returns boolean
  59.   if e.id = Event.WINDOW_DESTROY then exit   -- close the windows, bye
  60.   return super.handleEvent(e)
  61.  
  62.  
  63.  
  64.  
  65.  
  66.