Updating Display Boxes

I was recently asked a question about updating display boxes.  Display boxes are the building blocks of JMP output windows.  Fundamentally there are two methods of updating these display boxes, which I will take a closer look at.  

Method 1: Messages

Display boxes are used to display “content”.  Text is displayed in a Text Box, lists are displayed in a List Box or a Combo Box, clickable buttons are displayed using a Button Box.   Etcetera.

Associated with these display boxes are messages.  These messages can be used to change attributes of the display box (e.g. font style and colour).  Messages can also be used to perform actions: in particular, setting or changing the content of the display box.

If I want to update the contents of a Text Box I can send the message Set Text.  If I want to update the list items that are displayed in a  List Box I can send the message Set Items.  If I want to change the label that appears on a Button Box I can send the message Set Button Name.

To master display boxes and their associated messages you need to master the JMP Scripting Index found under the Help menu.  This lists all the display box types and their associated messages.  It also gives helpful example code to illustrate usage:

click to enlarge
click to enlarge

To illustrate the method, here is an example that displays a list using a List Box.  The contents of lst1 are displayed;  after 5 seconds the message Set Items is sent to update the display with the contents of lst2:

Method 2: Delete and Recreate

Sometimes we want to perform an update to a display box for which there is no corresponding message.  Often this is because we are performing some structural change to the content which is bigger than a single update to an attribute.  Updates can always be performed by deleting content and adding new content.   I’m going to illustrate this method by using the same scenario that  I used to illustrate the Set Items message above.

Specifically, I want to take the above code and after line 6 (the Wait statement) I want to recreate the display box contents.  This involves deleting the existing display box and creating a new one.  It helps to place my display box in a container:

A V List Box is a display box that is used to group and align one or more display boxes.  To delete the list box I can do one of the following:


Once deleted I can Append a new List Box to my container:

Here is the complete code:

The key to using this technique is having a container display box.  Suitable display boxes for this role are Panel Box, Outline Box, V List Box and H List Box.  The role of these display boxes is to contain other display boxes.  These are the ones that will be deletes and recreated.

Sometimes when content is deleted it causes the window to temporarily collapse is size (it will become apparent if you put a Wait after line 9!).  This can manifest itself as flicker when the update occurs.  You can prevent this happening by adding a “spline” that gives the window rigidity.  Let’s say that I want to ensure the window maintains a particular size, I can use Spacer Boxes horizontally and vertically aligned with my container:


Leave a Reply

Your email address will not be published. Required fields are marked *