|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Product Reviews Microline Component Toolkit 3.0
Microline Component Toolkit 3.0
By: Eric Ries
Mar. 1, 1996 12:00 AM
The Microline Component Toolkit (MCT) is a powerful new product with years of experience behind it. Designed for professional developers, but usable by even a novice, the MCT brings new levels of GUI sophistication to Java, and for the first time brings professional UNIX-style components to those who still believe that "Motif" refers only to interior decorating. The MCT carries all the advantages of slick, powerful, UNIX widgets without the complexity and single-platform constraints traditionally associated with them. Using Java, Microline has helped to usher in a new era in GUI programming. Wait a second. What the heck is a widget? No, it's not a troll from fantasy land or an aquatic midget. A widget is a name for a GUI component that performs some function. In Java, member Components of the AWT (like Lists, Choices, and Buttons) are all widgets; albeit simple ones. The Microline Component Tookit provides powerful new widgets based on those used in Motif X-windows operating systems. Many Microsoft Windows users are often surprised to learn that many of the new, snazzy features in Windows 95 and NT 4.0 have been on UNIX machines for a long time. Fancy widgets like expandable trees, right-click pop-up menus, and tabbed panels have been part of some Xwindows systems since their inception.
History
MCT Components
Grid Resizing columns is not the only interaction provided by Grid. In the previous example, each of the Buttons triggered a standard Java Event. Events can also be trapped when the user selects an individual cell, or an entire row/column. Double-click and other mouse/keyboard events unique to Grid can also be used to provide complex user interaction. Figure 2 shows a simple scenario that prints to System.out every time a row is selected.
Trees Trees are represented with both graphics and text, the default being the common folder/file combination. However, other icons can easily be used. The tree in Figure 3 uses custom icons and contains both vertical and horizontal scrollbars, when necessary. Vertical scrolling is done one row at a time, while horizontal scrolling is done one pixel at a time, making tree traversal very easy. Double-clicking an expandable node will collapse or expand it, as will clicking on the "+" or "-" that is next to the node. Both kinds of nodes can be selected easily, and a program can take action based on that selection. Most Trees are created all at once and then displayed. However, this can often be impractical for very large structures, especially when only part of the Tree needs to be displayed at any one given time. To account for this, the Tree class allows your programs to override the default expand/collapse behavior, and change the contents of the Tree dynamically. In a dynamic Tree, each folder expands to reveal another set of folders, added dynamically when the selection is made. In addition, when a folder is selected (single-clicked), a list of "files" contained in it is displayed in a column on the right. Remember, the Tree is really just a souped-up Grid.
TabPanel TabPanels can get very complex and exciting. TabPanel even comes with several different border choices and other options useful for customization. Like all MCT Components, TabPanels can contain text, graphics, or other Components. The tab labels themselves can handle text and graphics, too. The TabPanel in Figure 4 shows many tabs laid out in rows across the top. The TabPanel has many options for the sizing of tabs, and is usually quite intelligent. The Button used in this example allows tabs to be dynamically added to the TabPanel.
Progress Meters and Other Tools In addition to its AWT Components, the MCT comes with several utility objects that provide useful functions. One of the best is something called the IconMaker-a utility so useful you'll wonder why it's not included with one of the standard Java packages! The IconMaker allows you to create Image objects based on Strings, instead of having to store them on-disk as tiny GIFs or JPEGs. If used excessively, this can swell the size of your source code, but in moderation can make your life very easy. Observe the following example: This Image was created by the IconMaker using the following lines of code: Although this is hardly a great Object-Oriented Programming practice, it is far easier and faster than trying to design a silly little icon in an external graphics program. The MCT also comes with other utility objects, although none as eye-catching as the IconMaker. However, some of them do rival its utility: tools for word-wrapping, drawing, and shadowing are all included in the MCT's utility classes.
Drawbacks Although bugs in the MCT are rare, it does suffer from some of the AWT troubles that have plagued the Java language on PC platforms. The MCT also inherits some GUI bugs from the AWT that, through no fault of their own, make some of its classes hard to use. Microline has been working very hard with Netscape to eliminate bugs in that implementation of the AWT, and their efforts have paid off in the most recent Beta of Netscape Navigator, which handles MCT Components very nicely. Probably due to their many years of UNIX programming, MCT's designers have employed some non-standard Java techniques. The most obvious one that veteran Java developers may have some trouble adapting to is the notion of resources. Attributes of the MCT Components are not set via methods like setBackground() and setText(). Rather, they all use the same method, setValue(), to add and change resources. A resource is a string that represents a certain Component attribute. For instance, the TabPanel has a resource named "tabsPerRow" which defines the maximum number of tabs in each row. If this value is set to zero (or not set at all), all tabs will be put into one row. Now, this may seem like a flexible system; more flexible, in fact, than the one built in to the AWT. This is very true, and adapting to the resource system is easy and painless. However, it has its dangers. The Java design team had certain principles and goals that they imposed on the language, to ensure its security. One of these was the tenet that errors and unexpected behaviors ought to be caught at compile-time rather than at run-time. This prevents nasty bugs from plaguing helpless users. This is the reason for Java's strict type-checking and syntax rules. However, the resource system defeats this compile-time scrutiny. For instance, in one sample applet I tried to write, I accidentally typed "tabsPerSnow" instead of "tabsPerRow". The applet compiled fine, but the TabPanel did not place its rows as intended. Luckily, the MCT does handle errors like this at run-time. The program displayed the following error message in the standard out window:
Ml: WARNING: convert(): Unknown resource tabsPerSnow
Conclusion Many big, important companies have purchased the full MCT, and many more have tried out the lite version. The MCT has also been rewritten to support Netscape's new Internet Foundation Classes. The new product is called the Microline View Toolkit. Microline has also promised "additional", unspecified Components "soon". If you're a professional developer, the MCT is your top choice for powerful, professional Java widgets. Reader Feedback: Page 1 of 1
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||