Custom UI Components
I In certain cases, you may want to extend the default functions of the UI components or make custom changes. To do so, you can derive from the standard components. The new UI component can then be used in the GUI Builder.Â
Generate UI Component
- Click Project Management > User Interface Create a new GUI element.
- In the following dialog, choose a name for your UI component in Name, e.g. MyButton.Â
- Click Superclass > Browse.
- In the following dialog, choose a UI component from which you want to derive your UI component (superclass), e.g. XdevButton.
- Click on OK.
- Click on Finish.
Result:
A new UI component of type  XdevButton  is generated.
package com.company.example.ui; import com.xdev.ui.XdevButton; public class MyButton extends XdevButton { /** * */ public MyButton() { super(); this.initUI(); } /* * WARNING: Do NOT edit!<br>The content of this method is always regenerated * by the UI designer. */ // <generated-code name="initUI"> private void initUI() { this.setCaption("Button"); this.setSizeUndefined(); } // </generated-code> }
- In Project Management > User Interface a new UI component is available and can, thus, be displayed in the GUI Builder, edited, configured via Properties, and enhanced in the Java code view.Â
- The new UI component is automatically added to the Palette. The new UI component can be used in the GUI Builder like any other UI component.
Enhance UI component
The new UI component can be enhanced with any new properties and methods.
- Double-click the new UI component in Project Management > User Interface.
- Change the caption.
- Assign an icon to the UI component.
Define a new property; e.g., MouseOverCaption.
String MouseOverCaption = ""; public String getMouseOverCaption() { return MouseOverCaption; } public void setMouseOverCaption(String mouseOverCaption) { MouseOverCaption = mouseOverCaption; }
- Click Save.
Note:
- The properties defined in the code are later displayed in Properties > Misc.
Use new UI component
The new UI component can be used in the GUI Builder in the same way as any other UI component.
- Click Project Management > User Interface > MainView.
- Choose a new UI component in the Palette and drag it to the MainView.
Use new UI component in the GUI Builder as default
- Click on the small arrow on the palette in the derived UI component.
- Click in the new UI component..
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.