Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Choosing Swing or HTML - Universal Robots https://plus.universal-robots.

com/getting-started/choosing-swing-or-html/

Forum API Reference Download Center Getting Started


 

Since version 1.3.55 the URCap SDK allows URCap developers to


create their user interface in either native Java Swing, or a subset
of HTML. 
The purpose of this article is to outline the major differences,
pros and cons, to help you decide what version to develop. 

Keep in mind, that it is possible later on, to adjust your code to


use the other implementation as well, if you wish to change your
mind. 
For converting from (old) HTML URCaps, to Swing, read the
"URCap Converting to Swing" guide in the SDK.

Put in short, HTML is often easier to develop, and non-Java


programmers may find this easier, but offers a more limited
functionality. 
Swing may be more cumbersome, but provides the full UI feature-
set of Java Swing, to create more advanced and sophisticated
UI's.

Swing based UI was introduced in SDK 1.3.55, and supports


PolyScope version 5.0 and 3.6 and above. Hence, the robot must
at minimum run this software version, to support Swing based
URCaps. 
Java Swing is a GUI Widget toolkit for Java, and is used widely by
Java developers around the world. UR's PolyScope software is
based on a Java Swing user interface. 

Swing is the preferred UI technology used by URCaps. Hence,


this the recommended selection for most URCaps

1 of 5 12/05/2020, 10:03
Choosing Swing or HTML - Universal Robots https://plus.universal-robots.com/getting-started/choosing-swing-or-html/

Forum API Reference Download Center Getting Started


 
URCaps using Swing to build their user interface can choose any
UI objects, that are supported in JDK6. 
This includes elements such as: 

Alterable text (JLabel), with styling (font, size, bold etc.)


Text input fields
Number input fields
Special input fields (such as passoword or IP addresses)
Buttons (JButton)
Check boxes (JCheckBox) and radio buttons
(JRadioButton)
Dropdowns (JComboBox)
Lists (JList) for selecting multiple items on a list
Images
Spinners and sliders
Color choosers
Tables
Folder or file trees
Progress bars
Etc.

Each of the elements, can be styled in Java, to achieve the


appearance desired. It should though be noted, that the user
interface must comply with the URCaps Style Guide. 
Typically, the code lines needed in Java will be more extensive,
than the similar UI in HTML. However the richness of features
provided in Swing is also far superior to HTML. 

In Swing, the developer is responsible for linking the View-class


(the user interface) with the Contribution-class (the controller and
logic code), through public methods and callbacks associated
with the various UI elements. Furthermore, the developer is
responsible for handling grouping of changes, done by a user
event into blocks of "Undoable Changes" - this is handled
automatically in HTML. 
For most UI objects in Swing, the developer have to handle re-
styling objects if they switch between an enabled or a disabled
state. If it is desired to develop a URCap that is compatible with
both CB3 robots (PolyScope 3.6+) and e-Series robots

2 of 5 12/05/2020, 10:03
Choosing Swing or HTML - Universal Robots https://plus.universal-robots.com/getting-started/choosing-swing-or-html/

Forum API Reference Download Center Getting Started


 

HTML based UI's have been a part of the SDK since version 1.0,
any URCap will hence support this functionality. 
When developing a URCap with a HTML user interface, the
developer can use a limited subset of standard HTML elements
and attributes. 
The HTML developed in the URCap, is by PolyScope parsed into
the native Swing user interface, that PolyScope is based upon. 

HTML elements and attributes supported by the URCap API


follows a strict subset of code, that is documented in the URCaps
Tutorial. 
Deviating from this subset will result in errors, e.g. scripting such
as JavaScript is not supported. 
Typical elements, that can be used in a URCap HTML user
interface includes: 

Static and dynamically alterable text


Text input fields
Number input fields
Buttons
Check boxes and radio buttons
Dropdowns
Images

The URCap developer must create a linking between the HTML


code (.html-file) and the Contribution-class (the controller and
logic code) in Java. In HTML done by the "id" attribute, and for
example by "@Input"-annotations in Java. When an event
happens in the URCaps user interface, PolyScope will
automatically call the associated callback in the Contribution-
class, and any changes done to the data stored, will automatically
be grouped into an Undoable-block, the user can later un-/redo. 
Some layout management can be done using CSS styling, but in
general PolyScope handles implementing the UI elements, in a
way that is corresponding the the overall PolyScope look-and-
feel. 

3 of 5 12/05/2020, 10:03
Choosing Swing or HTML - Universal Robots https://plus.universal-robots.com/getting-started/choosing-swing-or-html/

Forum API Reference Download Center Getting Started


 

READ READ

Now you have learned the fundamentals of URCaps. 


Now let's put it into practice, by following the My First URCap
video article series. 

4 of 5 12/05/2020, 10:03
Choosing Swing or HTML - Universal Robots https://plus.universal-robots.com/getting-started/choosing-swing-or-html/

Forum API Reference Download Center Getting Started


 

This article is part of the "Getting Started" series of articles. 


There are 2 chapters: The Basics, and My First URCap.

1. Basics: Develop a URCap


2. Basics: UR Software Architecture
3. Basics: Principle of URCaps integration
4. Basics: URCaps API Overview
5. Basics: Choosing Swing or HTML
6. My First URCap: Introduction

Terms and Conditions Guidelines

Universal Robots A/S • Energivej 25 • DK-5260 Odense S • T: +45 8993 8989 •


sales@universal-robots.com
Copyright @ Universal Robots 2020

5 of 5 12/05/2020, 10:03

You might also like