9 Replies Latest reply on Apr 28, 2012 10:40 AM by 921640

    Customizing  HTMLEditor element

      Is possible to choose fonts which are avaible in html editor?
        • 1. Re: Customizing  HTMLEditor element
          David Grieve-Oracle
          You can extract html-editor.css from jfxrt.jar to see what styles it uses.
          1 person found this helpful
          • 2. Re: Customizing  HTMLEditor element
            I want to change this in my code. Is there any possibility to do it? I want to write portable desktop aplication and I cant modify runtime files. Maybe I can package my aplication with runtime and distribute with this modified file?
            • 3. Re: Customizing  HTMLEditor element
              David Grieve-Oracle
              Two ways. First, you can add your own stylesheet to the scene (scene.getStylesheets().add("stylesheet-url")). Or you can override protected String getUserAgentStylesheet() in Control to return the url to what you want as a user agent stylesheet for this control.
              1 person found this helpful
              • 4. Re: Customizing  HTMLEditor element
                I've seen this html-editor.css file. I think that you misunderstood me. I want to limit list of available fonts which end user can use to write document using this control. Do you have any idea for this?

                Edited by: adam on 2012-02-22 11:59
                • 5. Re: Customizing  HTMLEditor element
                  I want ask in addition.

                  How can I customise the HTMLEditor, not change merely the style, but if I want , for example, add some more functional buttons, like those "copy, paste, cut" on the right click in the context menu?

                  How can I generally change the component internals?

                  Is it possible?

                  • 6. Re: Customizing  HTMLEditor element

                    Sorry to bump-up this theme, but I need similar info on HTML Editor control.

                    Is there some comprehensive documentation, or even better - source code - or something like that, which could help us understand it?

                    Namely, me too would like to limit available fonts and some other things...
                    • 7. Re: Customizing  HTMLEditor element
                      Is there some comprehensive documentation, or even better - source code - or something like that, which could help us understand it?
                      There is source code but it is not (yet) publicly available.
                      I suggest you file jira requests (http://javafx-jira.kenai.com/) for:
                      (a) A supported public API for HTMLEditor customization.
                      (b) Documentation and tutorials for (a).
                      • 8. Re: Customizing  HTMLEditor element
                        Here is a gist link (https://gist.github.com/2514709) to a collection of interesting hacks for hiding stuff, adding new controls and changing the selectable fonts in the HTMLEditor.
                        The code at the link is modified from a StackOverflow question I answered previously http://stackoverflow.com/questions/10075841/how-to-hide-the-controls-of-htmleditor.

                        Beware that the hacks rely on internal implementation details of the HTMLEditor such as the number, choice and order of default MenuButtons in the toolbars, the hierarchical structure of the images in the buttons, the names of the images for the buttons - and this stuff can (and probably will) change in future implementations. For example I think it likely that the font selection MenuButton will be replaced by a ComboBox (possibly actually displaying the font face). One of the hacks I used also make use of a deprecated impl API. I tested the code and it works on JavaFX 2.1, but (perhaps) won't work in future JavaFX versions.

                        Until a more comprehensive HtmlEditor customization API is requested (by filing a jira with a link to this thread) and implemented, you could probably use similar techniques to those in the gist to perform other customizations on the editor. In addition to the techniques in the gist, as David pointed out, adjustments via a css stylesheet can also modify many aspects of the HtmlEditor and are generally a good way to go for these kind of things if they can get what you need done.

                        I totally get why you want to limit the font selection . . . on my Windows XP box the HTMLEditor was showing me 275 fonts to select from, which was kind of painful to deal with as a user when the font selection is implemented with a MenuButton style control - you have to look through all 275 to find the one you want and you don't even get any preview of the font to help with selection - so if you aren't choosing something you already know, you don't really know what the chosen font will look like.
                        • 9. Re: Customizing  HTMLEditor element
                          Thanks jsmith,

                          This stuff is working but is too risky. The point is: HTML Editor is NOT yet ready for (serious) use. This font limitation thing is essential if you use HTML Editor to actually create and edit web content (think web-safe or theme specific fonts), but is also important with JasperReports.

                          I think I'll stick with the good old TextArea for now. :)

                          P.S. I don't understand why is any Jira request needed. It's obvious that this control is bad and has low usability, it's not really in sync with the standard API and it's using some prehistoric ways to provide functionality it offers (like these font menu buttons). So, it's common sense to improve it. But, I'll file a request, as soon as the site is available.

                          Edited by: scekics on 28.04.2012. 03.37