Search |
||
GUI Design and SWTPosted by aiqa on May 19, 2005 at 10:46 PM PDT
For some time, I have been working on the GUI of a software that will be used internally at the company I work for. I faced some problems which are mostly related with internals of GUI design, not what is seen on the screen but how to organize the code to make it easy to understand, write bugfixes and make improvements on the software that is deeply connected with the GUI. Some of the subjects I will discuss here are related with swt and some are the hints that made my life easier as a programmer. I learned them by making mistakes and spending too much time on thinking the answer of the question "am I doing right ?". Later I recognized that I can not find the right solution by thinking. I must apply what seems to be the best solution as soon as possible to see if I get the results I wish to derive from that solution. You may have different experiences and better solutions to the problems that I will write here. If so please share them with me. Swing vs SWT Debate I mostly used Combo and Tree as the main widgets. (Widget is the general name of a GUI component is SWT). With Delphi I have always created an array with a Combo to store more values than the simple text of what a user sees when he expends the combo. Swt Combo can store an object. This is excellent. If it hadn`t I could create my custom widget which will be a compound of a Combo and an ArrayList. Because SWT uses native calls to operating system you can not easily write a class which extends Combo class but create a composite and add your components onto it (actually if you don`t mind your byte code not to be platform specific you can do by implementing a method which checks if the class has been extended) . This gives you the freedom that you used to get with Swing altough swing is more flexible. SWT development will not seem to slow down because it is the primary component of Eclipse IDE which is widely used. When you code for a company this becomes the primary requisite. SWT is easy to learn. Online API reference is hard to find but easy to understand. FormLayout is exteremly useful and once learned you can add new widgets without modifying your source code very much. SWT commuity is getting crowded. Not crowded ! SQL Queries Creating Widgets SWT Tree Imagine a layout that at the left side of the screen there is a Tree and at the right there are Combo and Text fields which show the detailed information about the record choosen from the Tree. I can also store database values of the fields in the TreeItemData object to reduce the number of database queries. SWT Combo Don`t Create Objects For example I used "choose city" combo (which queries city table from database) in 6 different composites .Besides memory consumption it also took too much time for my program to initialize because every instance queries the database. Using one city combo saved me. Someone should say "Oh man, Java is slow" ;) I guess there shall be some better methods for the ones I wrote here. A GUI driven software is a bit boring to write because you put one control here one there and try to guess "dummy" user responses. They find some properties hard to use then you change the way they seem or behave after decades of the first implementation of that property. Programming becames a social event where your GUI talks and your language must be clear. My homepage is www.projectme.org »
Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|