Move to specific position in TextFlow JavaFX - java

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

Related

Android Horizontal Layout with text wrap functionality

I want to create an layout, in which I should be able to add views dynamically and it should expand horizontally in a flow.
Here are things that I've tried:
Flow-Layouts
Problem with flow-layouts is that when using multiple textviews, if textview having long text, it takes whole textview to next line, but I want it to wrap the text and only move rest of the text to new line.
Spannable Textviews
I want to assign individual id's to views because when it's clicked it should highlight and function accordingly but with spanning it's not possible.

Show the last text on scrollview

I'm creating a calculator app. I want the scroll view to scroll as I add new elements (numbers and signs) but it doesn't scroll. Once the text reaches the end of the screen I'm unable to see new elements until I manually scroll.
Then
The remaining part of the text
Try to call scrollView.fullScroll(View.FOCUS_RIGHT) after every text update.

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

Inserting some colored line in TextArea JavaFX

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

Display text over the icon in JXLabel

I'm using SwingX label for a image select/preview.
I need to show both text and icon together but when I set icon the text disappear!
How can I show text over the icon on a JXLabel?
Thanks
there no issue with that, there are two ways
1.correct way (implemented in the API, good habits, blablabla)
JLabel.setHorizontalTextPosition(JLabel.CENTER);
// search for equivalent in SwingX
2.crazy way to set proper LayoutManager for JXLabel and put there another JXLabel to the desired coordinates Location

Categories

Resources