712 Graphical User (Web hosting ecommerce) Interface Components: Part 1 Chapter

712 Graphical User Interface Components: Part 1 Chapter 12 A MULTIPLE_INTERVAL_SELECTIONlist allows continuous range selection as described for a SINGLE_INTERVAL_SELECTION list and allows miscellaneous items to be selected by holding the Ctrl key while clicking each item to select. JList method setFixedCellHeight specifies the height in pixels of each item in a JList. Method setFixedCellWidth sets the width in pixels of a JList. Normally, an event generated by another GUI component (known as an external event) specifies when the multiple selections in a JList should be processed. JListmethod setListData sets the items displayed in a JList. Method getSelected- Valuesreturns the selected items as an array of Objects. Mouse events can be trapped for any GUI component that derives from java.awt.Component using MouseListeners and MouseMotionListeners. Each mouse event handling method takes as its argument a MouseEvent object containing information about the mouse event and the location where the event occurred. Methods addMouseListener and addMouseMotionListener are Component methods used to register mouse event listeners for an object of any class that extends Component. Many of the event-listener interfaces provide multiple methods. For each, there is a corresponding event-listener adapter class that provides a default implementation of every method in the interface. The programmer can extend the adapter class to inherit the default implementation of every method and simply override the method or methods needed for event handling in the program. MouseEvent method getClickCountreturns the number of mouse clicks. InputEventmethods isMetaDownand isAltDown are used to determine which mouse button the user clicked. KeyListeners handle key events that are generated when keys on the keyboard are pressed and released. A KeyListener must provide definitions for methods keyPressed, keyReleased and keyTyped, each of which receives a KeyEvent as its argument. Method keyPressed is called in response to pressing any key. Method keyTyped is called in response to pressing any key that is not an action key (i.e., an arrow key, Home, End, Page Up, Page Down, a function key, Num Lock, Print Screen, Scroll Lock, Caps Lock and Pause). Method keyReleased is called when the key is released after any keyPressedor keyTyped event. KeyEvent method getKeyCode gets the virtual key code of the key that was pressed. Class KeyEvent maintains a set of virtual key code constants that represent every key on the keyboard. KeyEventmethod getKeyText returns a String containing the name of the key that corresponds to its virtual key code argument. Method getKeyChar gets the Unicode value of the character typed. Method isActionKey determines if the key in the event was an action key. InputEvent method getModifiersdetermines if any modifier keys (such as Shift, Alt and Ctrl) were pressed when the key event occurred. KeyEventmethod getKeyModifiersText produces a string containing the names of the pressed modifier keys. Layout managers arrange GUI components on a container for presentation purposes. FlowLayout lays out components from left to right in the order in which they are added to the container. When the edge of the container is reached, components are continued on the next line. FlowLayoutmethod setAlignment changes the alignment for the FlowLayoutto Flow- Layout.LEFT, FlowLayout.CENTERor FlowLayout.RIGHT. The BorderLayoutlayout manager arranges components into five regions: North, South, East, West and Center. One component can be added to each region. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01

Leave a Reply