I cannot find so much documentation in JavaFX.
And I will be happy to know how I can do this :
When I type a word in a textarea, fx "google" or "facebook". Can I so do like it can change color of google to fx green, and changes the font and stuff like that.
I will be happy to know how i can do this :).
No. JavaFX 8 does not support multiple colors for text in TextArea.
You could try Tomas Mikula's RichTextFX control and see if that works for you.
RichTextFX provides a text area for JavaFX with API to style ranges of text. It is intended as a base for rich-text editors and code editors with syntax highlighting.
The other options are:
To use a HTMLEditor OR
Embed one of the many HTML based text editors (e.g. CKEditor).
Adopt a markdown style editor, where the user just edits plain markup text in a standard TextArea and the styled text is shown in another pane (similar to how StackOverflow works).
Addressing additional coments
I found a place, there tell me that I can use TextFlow. So i will try this
TextFlow is a readonly control, not editable like a TextArea is. Creating an feature rich styleable text editor from scratch using only core JavaFX 8 components is a large and complicated task, which I would not advise most people to undertake. Instead, using or contributing to existing JavaFX editor solutions such as RichTextFX or other similar projects which may arise would likely yield better results and a more productive outcome.
Related
I want the user to have a pdf with an editable field and when the user clicks on the field, it should prompt a drawing tool where he signs or draws anything he wants. When this "image" is done, it should stay inside the borders of this editable field. Is this possible using Itext?
This development will be made in Java.
PDF is not meant to be a replacement for MSPaint.
So this kind of behavior is not going to be available out of the box.
What's important to note here:
the PDF standard itself is working against your use-case
iText only supports the PDF standard
Solutions:
Build a PDF viewer that enables this kind of behavior (there is a company called DocuSign that implemented a similar use-case to allow users to insert their autograph in a PDF document)
Build a plugin for a PDF viewer (e.g. Adobe Reader) that enables this kind of behavior
(warning, dirty hack) insert thousands of tiny interactive components in the PDF document (PDF documents do allow interactive textboxes and checkboxes, etc). Add javascript to your PDF document to register mouse movement, and color the interactive elements based on whether the mouse moved over them or not. I doubt however that this solution would be very performant.
i am a beginner in javafx and hence designing the form for desktop application in javafx. I am using netbeans. i have gone through some javafx tutorials.
My problem is i am trying to embed my custom css to my javafx code and i am using SceneBuilder with netbeans. Now, the changes or the tags in my css is not reflecting the change in my UI.
For ex: if it is background color- if i use .login{-fx-background-color: #368ee0;} in my css it works, but if i write .login{background-color: #368ee0;} it does not work. I don't know where am i doing wrong.
Please help and i can provide some part of code or some file for your ref. if required.
-fx-background-color is a valid JavaFX attribute, but background-color is not (so don't use it).
Only the CSS attributes which are defined in the JavaFX CSS reference guide are valid in JavaFX - you can't use CSS attributes designed for HTML such as background-color.
Is there any library which provide a text panel with basic formatting features.
Such as line numbering, Keyword coloring and others.
I want to display a code inside my application window. I already try to use JTextPane. But it is easy if there exist are any UI Components that meets my requirements.
note : I want to display the code same as when it is open using notepad++ or any code editor.
I've used jsyntaxpane with some success.
I want to create a java application that allows users to import a web page and be able to edit it within the program.
Importing a web page will render it and the components of the page (images, text, etc) will be editable or draggable, allowing the user to re-layout the components.
For example, the user can load a web page that has an image header, but decides to have it at the bottom of the page. They can simply click and drag the image down and the html will be reformatted appropriately. It is basically a WYSIWYG html editor...
Will this be a difficult task? I am stuck at how to parse the web page into draggable components and being able to export the html after all the edits.
From what I can see, I'd need wrapper classes for html components and a way to keep track of all the changing positions and objects, but I could be wrong. Are there any helpful tools for this task?
I think creating something from sctratch will be difficult. But you can use Eclipse Web Tools Platform (either just by installing it or by developing your own plugin/distribution based on that). It has a fairly good HTML Editor/Web Page Editor which has WYSIWYG features.
EDIT: Also this question has some tips: Java WYSIWYG HTML editor
I have a small (500kb) swing applet that displays very simple/limited set of small HTML page(s) inside it with JEditorPane, however this does not seem to work 100% fluently, some customers get a blank page displayed without any java exceptions. The page works OK from my machine. I need a more reliable way to show HTML page to all our users.
Any ideas if there is a small + free class to use instead of JEditorPane
OR is there an easy fix to make it more reliable (non blank)
private JEditorPane m_editorPane = new JTextPane();
m_editorPane.setEditable( false);
m_editorPane.setBackground(new Color(239 ,255, 215));
m_editorPane.setBounds(30,42,520,478 );
m_editorPane.setDoubleBuffered(true);
m_editorPane.setBorder(null);
m_editorPane.registerEditorKitForContentType("text/html", "com.xxxxx.SynchronousHTMLEditorKit");
m_editorPane.setPage(ResourceLoader.getURLforDataFile(param.trim()));
Although I haven't used it before, Lobo is an open source web browser for Java with support for HTML 4, Javascript and CSS 2.
Compared to the JEditorPane which only has support of HTML 3.2, it seems like Lobo may be a better bet for loading modern web pages.
AFAIK, JEditorPane is a very primitive HTML component: it is confused by CSS and knows nothing about JS.
I doubt you will find a "small + free" class doing better, HTML parsing and displaying isn't a simple business, even less today.
Perhaps it is better to let the big names in the business to take care of this task, ie. using Internet Explorer or Mozilla components (depending on what is available, etc.): JDIC: Embedding a Web browser in Java.
I've recently POC-ed several java HTML rendering solutions. We decided on JEditorPane because we really need to minimize the size of our jar and it's built into Swing. However, the best library I came across was Flying Saucer. It doesn't have any js support but it's rendering quality and api is top notch, and it's "free" (LGLP), 100% Java, and only about 1mb (still too big for us, but small compared to other options). However, it only renders strict XHTML (all attribute values have to be quoted, all tags properly formed), but that may be OK depending on your needs (and HtmlCleaner or some other such utility may help towards that end).