I am currently trying to get into JavaFx and started writing a program similar to Microsoft Word or Pages on OS X. I had to realize that the TextArea is really limited when it comes to style, so I was wondering if there is a component that is editable (as in you can write on it) and is able to change font size/color dynamically (size and color are defined with a choicebox on the UI.
I read a little but about binding style-types or setting css rules, but as far as I know there is no way to access Java components (choicebox) or even variables from the css style sheet, so it wouldn't be dynamical.
What I mean by dynamically change font size/color:
Type a character into the TextArea.
Double the font size.
Type another character, that now appears twice as big as the first one, that is still displayed in its original size.
I'm having a hard time explaining myself, if you have any questions, please ask and I'll try going into further detail. Thanks
EDIT: Something that might be important is the fact that I am using Scene builder to create my UI.
EDIT 2: Could I cheat my way around it using a Highlighter with the same color as my background?
Related
I'm trying to use the text component of JavaFX to do some nice headline typography in my application. How ever the letters in the text are not spaced evenly. For example in the word "visiting", the "iting" part seems disconnected from the first part.
In the sample image I'm using Arial but this kind of bad spacing happens with every font I tried.
This only happens when "gray" anti-aliasing is used (-fx-font-smoothing-type: gray;). One obvious solution would be to change -fx-font-smoothing-type to lcd, but that would result in the text having jagged edges.
The only thing remotely mentioning something like this is the jira issue RT-14187, but that seem to have been resolved in javafx 8 (jre 8).
I'm new in Swing, and don't want to learn it. I just want to write a simple frame divided into two equal parts: top and bottom. The top part of frame should be a simple immutable text field.
Problem: As I understand, to show text with beautiful font I should use JTextPane. But JTextPane:
Doesn't support vertical text alignment; (I haven't got any desire to write something like that)
I don't know how to switch off editing.
Quedtion I believe there is a simpler solution for my purpose. Is there?
The top part of frame should be a simple immutable text field.
Use a JLabel. It supports HTML which might help with your formatting.
I don't know how to switch off editing.
setEditable( false );
I own a sports apparel company and I'm looking to have an applet built that will allow customers to see how their team names will look in certain colors on jerseys. Below you can see the final result of a competitor site's Flash applet where text is rendered on 2D surfaces/images.
My requirements: I need users to be able to set the font, primary text color, outline text color, and text style (arched or straight).
So my question-- Is this sort of text rendering possible with only Javascript/PHP?
If so, what limitations do you for see? I've been told the arching and outline text color may be issues. I've also been told that I may have to upload library files to a server where the actual rendering may take place.
If not, what scripting would you guys recommend? I'm trying to stay away from Flash because it's slow and costly.
I'll be passing this onto our developers so please feel free to be as detailed as possible. I figure'd I'd save them some leg work!
Thank you!
Depending on how complex you want your graphics to be, html5 drawing abilities could be used. Check Raphaƫl library, for instance, webGL/canvas renderers already have a lot of features in modern browsers.
As of the solution with server rendering, it's also possible with gd2(php), but imho that would be less convenient, at least try something different from php (btw, what's your backend running on?)
Your competitor's solution with java applet honestly seems the easiest, except that it requires jre, which few people are eager to install =)
That's kind-of a high level question, but yes you can definitely use javascript for it.
If there's a problem with getting characters to look right, you can always save each letter as a separate image and have javascript place them next to each other in preview. I'd try to see how close you could get with the existing fonts first.
Layering the text: one color large font, then a different color smaller font will give you the outline effect your looking for.
I'm trying to implement a basic text editor with options for font, bold, italic, underline, and color. I've used JEditorPane and the associated HTMLEditorKit but when I load a 400K document it takes a full minute to load and most editing takes several seconds.
I've had a similar experience and what I did was to get the JEditorPane to only show a page sized window onto the 400K document (if this is possible in your situation) and then manually deal with scrolling issues.
That way I got a lot of cool functionality from the widget without the massive slowdown (cos the widget only saw part of the text), but I had to write a load of scroll code and keep updating the widget contents as users moved around.
Plus I was doing it so I could view 7G files, which were not going to fit in an memory I had anyway.
http://java-sl.com/JEditorPanePerformance.html
May be some of the tips could help you to make it a bit faster. I would also recommend to write your own EditorKit based on e.g. StyledEditorKit with all necessary attributes support (see for example http://java-sl.com/editor_kit_tutorial.html).
I'm looking for a highly efficient Swing Java component which I can just plug into my application UI. I already tried using the classes within Swing such as JTextArea with no avail; they simply aren't high-performance enough and have any crippling drawbacks. Additionally, it'd be nice if it had standard console features such as scroll-lock, clear console, colours, and so on.
Edit: Forgot to say, this console will have a lot of debug information streaming into it, and it needs to be fully scrollable.
Cheers,
Chris
I fail to see what is wrong with using a JTextPane. It supports attributes which you can specify as each piece of text is added to the console. Clearing it is also obviously a no brainer. When added to a scroll pane it also supports scrolling.
You can add scroll locking by using Smart Scrolling.
Plus, it removes text too early and
No idea what that means as text is never removed unless you specifically remove it from the document.
doesn't allow the user to scroll while
input is being entered (afaik). The
effect is that you just see text
flashing while the number of rows
remains the same.
By default the text scrolls automatically as text is append to the document assuming the code is executed on the EDT. This scrolling can be controlled the the example provided in the link above.
Edit:
but I'd still like a library solution
I don't know of any
auto-colourise text coming from
different streams
The Message Console might give you some ideas.
(i.e., detect [error] prefix on a
line) and colourise lines based on
this)
This is easily done by adding a DocumentFilter to the Document of the text pane. You can add attributes as text is inserted into the Document.
Be sure that you read about the Event Dispatching Thread (EDT) in swing!
BTW: a simple search 'java swing console' will give you a lots of hints OR you could use/adapt the beanshell textfield which is a jtextfield too ...