View RSS Feed

Java Swing

The component hooks

Rate this Entry
by , 04-26-2012 at 07:39 PM (604 Views)
Look and feel behavior of every swing component defines swing.plaf package’s abstract class for representation of UI delegate. These classes naming convention is taking class name for sake of component, append UI and remove prefix

In constructor of component, UI delegate is made, of which access is given as “JavaBeans” bound property, at the component. For instance, following methods are provided by JScrollBar for access of UI delegate.

Java Code:
   public ScrollBarUI getUI()
   public void setUI(ScrollBarUI ui)
UI delegate creation process and its setting up as UI property is installation of look and feel of component.
A method is also provided by every component that set or create the UI delegate for look and feel that is “default”.

Java Code:
   public void updateUI()
For every abstract, plaf UI class, concrete subclasses are provided by the implementation of the Look and feel. For instance, WindowsButtonUI, WindowsScrollBarUI or so on are defined by the Window look and feel. When UI delegate is installed by a component, there shall be some way for looking up the proper concrete classname, dynamically for current look & feel. Hash table is used for such operation where programmatically a key is defined by getUIClassID() method present in component. Plaf abstract class is used for these keys. For instance, following is provided by the JScrollbar:

Java Code:
public String getUIClassID() {
   return "ScrollBarUI";  
}

Submit "The component hooks" to Facebook Submit "The component hooks" to Digg Submit "The component hooks" to del.icio.us Submit "The component hooks" to StumbleUpon Submit "The component hooks" to Google

Comments