Writing Custom UI Controls
richard.bair at oracle.com
Mon Jul 16 08:16:25 PDT 2012
Extending Control carries with it certain benefits:
- it supports tooltips directly
- the skin of the control can be changed (from code or CSS)
If the reusable controls you want to build are intended to by style able (especially if intended to be reused outside your current application) then extending Control is the right way to go.
There is enough public API that you can create controls and skins yourself that will interoperate, however you have to provide some infrastructure yourself such as how to handle CSS styling (have your skin implementation extend region) and how to handle multi-platform keystrokes (since behavior is not public). The Lombard (nominally, 3.0) product plan includes an item about making more of this infrastructure public so that you can more easily create well behaved controls.
One thing we've discussed is to have Control extend Region and create a public SkinBase, replacing our current one, for example. So for sure you cannot rely on our private API since we have ideas that those private classes might be removed.
Of course, those classes are open source so you can copy/paste our implementation in your own project as long as you are in compliance with the license. GPL makes this kind of a pain though for commercial apps.
On Jul 16, 2012, at 7:20 AM, Elisa Deaibess <elisa.deaibess at gmail.com> wrote:
> Thanks again Greg. For sure I'll look at the recommended FXML
> Can anyone please advise if it is safe to use
> is it considered "public"? Or it can be removed in the next releases?
> On Mon, Jul 16, 2012 at 4:22 PM, Greg Brown <greg.x.brown at oracle.com> wrote:
>> For small, self-contained controls like a search field or breadcrumb,
>> option #1 is probably best (though I'm not sure if it is considered
>> "public" yet - someone else may want to comment on that). For more complex
>> controls that aggregate other controls (such as a ribbon), I'd suggest #2.
>> I'd also highly recommend looking into FXML if possible.
>> On Jul 16, 2012, at 9:07 AM, Elisa Deaibess wrote:
>> Thanks Greg for your response.
>> Currently we aren't using FXML, we are using JavaFX java api.
>> On Mon, Jul 16, 2012 at 3:55 PM, Greg Brown <greg.x.brown at oracle.com>wrote:
>>>> We are writing a new application using JavaFX 2.x. Our application needs
>>>> some custom controls such as a searchfield, listoptions, ribbon,
>>>> breadcrumbs, etc...
>>>> We decided to write common reusable controls; To do that we have 2 ways:
>>>> 1. Make our controls extends Control and create new skin
>>>> 2. Extend some layout container or other control
>>> JavaFX 2.2 contains some new features that make #2 much easier if you are
>>> defining the structure of your custom controls using FXML. See the "Custom
>>> Components" section of the "Introduction to FXML" document in the 2.2
>>> Javadoc for more information.
More information about the openjfx-dev