Generic Logic, Inc.

GLG Programming Tutorial for Java

Overview 5

Types of Glg beans 5

Classes and Packages 5

Jar File Usage 6

1. Structure of Typical GLG Java Application 8

Adding GlgBean to an Application Interface 9

Using GlgBean in a Stand-alone Java Program 9

Using GlgBean as an Applet 10

Using GlgBean as a Component of an Applet 11

Subclassing GlgBean 11

Loading and Displaying a Drawing 13

Initializing the Drawing 17

Handling Dynamic Updates 20

Example of Handling Dynamic Updates 21

Handling User Interaction 23

Overview 23

Handling Input Events in a GLG Control Widget 26

Using Low-Level Input Events 26
Using Integrated Input Actions 28

Handling Object Selection 29

Using Select Callback 30
Using Input Callback to Handle Object Selection via Integrated Actions 31
Using Input Callback to Handle Low-Level Object Selection using Object IDs 33

2. Using GLG Components in Java 34

GLG Bean Classes Used to Display Graphics 34

Performance Optimization 35

Mixing Heavyweight and Lightweight Components in a Swing Application 35

Using Java Applet in a Browser 35

Using Timers for Dynamic Updates 35

Generic Logic, Inc.