Skip to Content

How to add helpful options to the Status-Bar control

Estimated Reading Time: 1 Minutes

There are some user-friendly options that are often displayed on the status bar at the bottom of the screen.
These include whether the caps lock, num lock, and insert mode keys are on or off, as well as the current date and time.

isCOBOL's status-bar doesn't have these options, but they can be added with some OOP using the "Toolkit" and "KeyEvent" Java class.Attached is a sample that you can use.

The CLASS-ID program called "utility.cbl" will get the status of the num, caps, and ins keys as well as the current date and time.
The "test-statusbar.cbl" refers to this program to populate the status-bar.
For instance, this line in the SHOW-STATUS paragraph:

   modify hSt panel-index 2 panel-text utility:>caps()
Uses this method in the Utility.cbl file to determine if the caps lock is on or off:
   IDENTIFICATION DIVISION.
   METHOD-ID. caps as "caps".
   WORKING-STORAGE SECTION.
   77  state OBJECT REFERENCE boolean.
   77  l-string pic x any length.
 
   PROCEDURE DIVISION returning l-string. 
   MAIN.
      set state to Toolkit:>getDefaultToolkit():>getLockingKeyState(KeyEvent:>VK_CAPS_LOCK).
      if state
         move "Caps ON"  to l-string
      else
         move "Caps OFF" to l-string
      end-if
   END METHOD.
The screen with our enhanced status-bar looks like this:

And because the test-statusbar.cbl calls the "utility" class every second in a thread, the seconds roll forward on-screen.

How to add helpful options to the Status-Bar control
  • Attached Files
  • kb342.zip (2.09 KB) 35