Graphics User Interfaces

来源:互联网 发布:如何评价赵雅芝 知乎 编辑:程序博客网 时间:2024/04/29 22:49
Graphics User Interfaces
The world has changed a lot since GUI (Graphics User Interfaces) came to this planet. GUI has become standard user interfaces nowadays no matter what kind of software is. There are a lot of platforms and Operating systems which support GUI. There is also thousands of tools to create GUI applications. The implementations and methods vary, though, the mechanism is analogous.
First, all GUI systems have a lot of containers or components which represents all GUI widgets such as frame, window, button, label, toolbar, menu or dialog. Those components and containers have an inheritance hierarchy and ones which on top of hierarchy tree can hold other components and containers. So you can put label, button on window, and you can put a window on a frame, and so forth.
Second, all GUI systems are message-driven or event-driven, that is, no action would be taken until receiving messages and events which represents user actions. The applications will do nothing, for example, until user clicks some buttons or menus. You, the developers, are only responsible for writing events handling for each widgets which can receive events. The Operating Systems, however, are responsible to detect user actions and translate them into events and send them to your applications.
Third, every widget has their own attributes which specify some appearances or some actions that widgets should act when user sends events to them. Window, for example, has attributes of height, title, size, caption .etc. The widgets can work properly and the GUI is meaningful only you set the rightful attributes of them.
Fourth, containers or components have some layout schemes which is responsible to organize widgets put on them. It is hard to use when menu is on the bottom of window and button is in the text input areas.
So, writing GUI applications is not as difficult as you think, you decide what kinds of contains and components you want use, set attributes for each them, and use a layout scheme to organize them. Then write event handling for each widget. After that you are done almost.


About Java’s GUI
Java follows the common patterns, too.
Some components and containers such as frame, dialog and panel can hold other widgets. There is some Layout manager to help to organize these widgets(BorderLayout, FlowLayout and BoxLayout). There are thousands of attributes for each widget to control all the things you can see and things you cannot as well. For each widgets you can add event listener to them to let them do what you want. So what you have to do when you program with Java GUI is: set attributes for widgets which you want to use, arrange them onto some containers according to some layout schemes. Then write event handling methods for widgets. After that you are done.