JavaFX TextArea right alignment - java

I tried to use the TextArea component to let user write multi-line text,
but the problem that I can't set the text alignment to right. By default it starts in the left.
The text will be in Hebrew or Arabic, so I need the user to write in the TextArea from right to left. I didn't find from the TextArea code and docs a way to do that, and in some forums some people said it can't be done. Is that true?

If you are using Scene Builder to build the FXML, then simply set Node Orientation property to RIGHT_TO_LEFT. You should see the result as soon as you run "Preview -> Show Preview in Window", where the cursor and typing happen on the righthand side.
If you are creating the TextArea inside a JavaFX application (no FXML), you use the method setNodeOrientation() on your TextArea object with the enum parameter NodeOrientation.RIGHT_TO_LEFT.

Related

JavaFX default element

So I'm just starting to learn JavaFX, and I made a couple of TextFields with Scene Builder. I assigned some prompt text to every TextField, but when I start my application, the first TextField is already selected, so I don't see the prompt text. Can I do something about it?
One solution is to make the prompt text stay visible when the TextField has focus.
The reason why the prompt text disappears is because modena.css (the default stylesheet used in JavaFX 8+) makes the prompt text's fill transparent when the TextField has focus. You can change this by using your own CSS to style the prompt text. There are a couple ways you can do this:
CSS File:
.text-field:focused {
-fx-prompt-text-fill: inherit;
}
Code:
textField.setStyle("-fx-prompt-text-fill: inherit;");
Note you can set the style from Scene Builder.

ReadOnly Text Area with Scroll in JAVAFX

in my JAVA FX application I am using TextArea to display certain text content. I am using following property to restrict editing:
templateScriptArea.setEditable(false);
With this, user is not able to write anything on TextArea, but selection is allowed, or if any selection is made by application is able change by user.
My requirement is that TextArea should be completely readonly, no editing no selection. Only scroll should work.
I thought, disabling TextArea is good idea with :
templateScriptArea.setDisable(true);
But, scroll not work with this and grey color appears on TextArea.
Is there any better solution?

How to disable horizontal scrolling in org.eclipse.epf.richtext.RichTextEditor

I have an Eclipse RCP application that has a widget that uses the rich text editor from org.eclipse.epf.richtext.RichTextEditor. So all the code is open to me to alter to how I see fit. I have found that the rte uses a browser to display the text.
My problem is that I want the rte to wrap the text and not put a horizontal scroll bar. So I was hoping to see if anyone has used this rte and figured out how to do this.
I think that in every SWT widget's constructor you can pass a style. So for example if you want vertical scroll but no horizontal you can do this:
new MyWidget(parent, SWT.V_SCROLL);
This way the widget won't scroll horizontally. the RichTextEditor itself does not have anything about text wrapping in its API so I guess that you can't alter that directly.
A little more about SWT styles: SWT style bits
Examine the HTML which is displayed in the SWT browser widget (call getText()). That should give you an idea how it's organized. Find the HTML element which wraps the editor, set it's width to 100% and make sure you do the same for the body and html elements to have the widget's width propagate to the editor element.
That should already fix the issue unless the text in the editor contains elements which are wider than the widget.

problem with textarea in javafx?

I used textarea in javafx 2.0 but i need to add it scrolpane.how can i do that?
Scrolllpane s = new Scrollpane();
s.setnode(textarea);
but when i click on scroll pnane it has doesn't move.
what is problem?
setNode() is the right method to call to set the node that the ScrollPane will scroll over. I've used ScrollPane extensively in my 2.0 app, but I have not tried it on Text Area. Based on the API documentation for TextArea (http://download.oracle.com/javafx/2.0/api/com/javafx/preview/control/TextArea.html) it sounds like it has its own built in scroll bars? I would try setting the width/height of the TextArea, and also set the max width/height, and see if you can trigger scrollbars to appear automatically when the lines in the text area exceed the available space.
If you still want to put it in a ScrollPane, perhaps with some other nodes, you should use a container node such as VBox or something to wrap the TextArea, then set the VBox to be your scroll node on ScrollPane.
Also, bear in mind that TextArea is not a committed control for FX 2.0 yet and is therefore less hardened than the other FX controls.
When we create a text area, scroll bar automatically appears when it goes beyond t

how to make java run time sizable image box

I'm making a Unicode translator in Java. I did all hard parts, but now I want to add a resizable, relocatable image to the textpane. The user must be able to resize image with its corners and drag & drop the image within the textpane where he likes. (like Microsoft Word or Photoshop)
Something like this:
I tried the Styled Document properties. But I couldn't find way except inserting only an ImageIcon.
May be a better choice would be not to use textPane.
If you have an custom editable label, that can be edited by double clicking on it to show a text box to edit the contents, and change the text of the label when enter key is pressed.
Also give a shot of JDesktoppane, JLayeredPane, and check what components can be added to it.
try this
http://mgeisler.net/downloads/browser/src/ImageBox.java.html
try loading the image inside a JLabel component in JFC Swing.
Otherwise try some other non editable components in the same technology with resizable property.
try this http://sourceforge.net/projects/ird/
the iRD is a component for Resize and move(drag&drop) compoennts on runtime in java.

Categories