Inserting some colored line in TextArea JavaFX - java

I need to insert some text line with red color in TextArea to print some statistics.
How can I proceed
Thanks

Use one of the available styled-text controls - see https://github.com/TomasMikula/RichTextFX/wiki/JavaFX-Controls-for-Code-Editing for a list of available ones or create a viewer based upon ListView yourself

Related

How to change color of single line inside textarea using javafx controller

I have textarea which show file data content. I have table view which contains line numbers and when double click on table view I can able to retrieve line number so I need to change the color of particular line number in textarea using JavaFx controller. How to do that? Please share your code. Thanks.
Please provide some code.
With the TextArea UI-Control you can only add color to the whole containing text.
For your purpose you should use HTMLEditor to style your text content individually.
See also: Using JavaFX UI Controls - HTML Editor

Libgdx how to set space between the check box and the text label

I've created a checkbox skin for libgdx Scene2d but the problem that there is no space between my checkbox and the text label , here is my code for the checkbox :
final CheckBox vSyncCheckBox = new CheckBox("vSync", skin);
vSyncCheckBox.setChecked(vSync());
vSyncCheckBox.getCells().get(0).size(30, 30);
and in the table layout i tried to use spaceRight(10); but nothing happens :
table.add(vSyncCheckBox).top().expandY().spaceRight(10);
here is the image on what the checkbox looks like for the moment:
Like you can see the checkbox and Vsync are stack together any help on how to provide some space between them ?
This is how you set space between the check box and the text label.
final CheckBox vSyncCheckBox = new CheckBox("vSync", skin);
vSyncCheckBox.getLabelCell().padLeft(10);
This is how I solved my similar problem:
table.add(yourButton).padLeft(Distance).OTHER_STUFF;
Next time please refer to the Wiki table page to solve any problems of or relating table layout
If you have any problems in understanding the concept turn on debugging
table.setDebug(true);
If your check box and your label is one single item, you can just simply put some space " vSync" in your declaration of the object instead of "vSync".
Could you please post the whole code of that table? It might be not working because of other settings made to the table.
Also, it can be helpful to activate debug mode by using
table.setDebug(true); // turn on all debug lines (table, cell, and widget)
Source: https://github.com/libgdx/libgdx/wiki/Table#debugging

Move to specific position in TextFlow JavaFX

I'm having a TextFlow inside a StackPane which is inside a ScrollPane. I'm adding text with different colors to this TextFlow
Text txt = new Text(msg);
txt.setFill(Paint.valueOf(color));
txtFlow.getChildren().add(txt);
I want to scroll to a some specific point in the textflow.
e.g. First text that is in blue color.
I know I can get the text and check the color. But how can I scroll down to that specific position?
Can I achieve that sort of functionality through the TextFlow?
Simply I'm trying to build up a diff view in JavaFX. And want to travel through the diffs.
I would take a ListView and put some stackpanes or directly the texts in it.
Text content = new Text("Custom Text");
content.setFill(Color.valueOf(yourcolor));
ListView<Text> list = new ListView<Text>();
list.add(content);
Because...
there's a void scrollTo() where you can scroll to the item directly by the Text object or to the item by the index (int).
To get a transparent background on the listview you can use:
list.setStyle("-fx-background-color: transparent;");
I hope this helped you.
I'm sorry if I missunderstood your question.
Peace
Use one of the free styledtext-editors - they all are using ListView or VirtualView internally. See https://github.com/TomasMikula/RichTextFX/wiki/JavaFX-Controls-for-Code-Editing for examples

Insert ICON/PNG inside TextArea

Without resorting to wrapping a GWT TextArea in a separate DIV, how to add a search icon/magnifier icon inside the text area?
No, Not possible.Text area is not a normal Widget.
GWT's TextArea maps directly to a HTML TextArea thats why you can only set text to it. The only thing you can do ist create a Grid/VerticalPanel/HorizontalPanel and put in each cell a separate TextArea.
Google Groups
Similar Question
Use a Composite wrapping a FlowPanel, put a text area and an image inside, then in CSS position the icon absolutely so it's over the text field.

How to design receipt panel in swing?

I have created general bill maker application on swing in which i've to print receipts as the output.
Basically i am not able to understand how can show the list of items on the panel so that it is able to print?
I am using PrintUtilities.java to print
the receipt panel.
What i am trying is to use a JTable for listing item details but if number of items is more than scrollpane viewport hieght than the rest of extra items are not shown and thus unable to print.
What can be the other way if i do not use JTable?
Or a solution with JTable itself.
What i want is to extend my whole dialog vertically if no. of items exceeded rather than using autoscrolls in JTable's scrollpane.
I hope i am clear to my question.
Here is the image of what i am trying.
I wouldn't use Swing components as printed components. Instead I'd build a PDF of the receipt and let the user print that. Scrolling is just going to be a problem with printing actual swing components that isn't easy to handle. This is a great PDF library:
http://pdfbox.apache.org/

Categories

Resources