Как выделить цветом в java
Перейти к содержимому

Как выделить цветом в java

  • автор:

Как выделить цветом в java

Remember that in Java Programming the background color and text color of the output screen is black or white by default. If we want to Highlight some text on the output screen then we can use the ANSI color codes and highlight the particular text. One can refer to the ANSI escape code in order to explore more.

Syntax:

As perceived from the above syntax contains This Syntax contains 3 parts:

  • In ANSI_COLORNAME we have to write the name in which we have given the particular ANSI code. for e.g public static final String ANSI_BLACK = “\u001B[30m”;

The above is pseudo-code is to print text in black color. So here we can use ANSI_BLACK in place of ANSI_COLORNAME to print the text in Black color.

Как сделать строку любого цвета JAVA?

str25 += («\n» + «\n» + no.obl25 + » » + ur.url25 + «\n» + » Призначений: » + result6001 + «\n» + » Звільнений: » + result6002);
String string =»»;
String string1 = «»;
if (result6001.size() != 0)
string +=»\n» + » Зміни:» + no.obl02;
else string1 = » Інші зміни відсутні»;
jtextarea.apped(str25);

цвет str25 я хочу изменить в случеи виполнения if. буду благодарен за любые подсказки или ссылки на литературу

Выделение изменений в Java

По сути, я сделал свою программу так, чтобы она отображала различия в строках и отображала всю строку. Я хочу выделить (цветом) различия в строке.

В этом примере ширина отличается от «оригинальной» от «отредактированной» версии. Я хотел бы выделить эту разницу и любую другую разницу.

Мой код на данный момент:

Это отобразит две целые строки, как в предыдущем примере (исходная и отредактированная версия). Я хочу иметь возможность выделить фактически внесенные изменения, есть ли способ сделать это в Java?

4 ответа

Есть ли конкретная причина, по которой вы пытаетесь переписать общие инструменты, такие как WinDiff и Beyond Compare?
Если это действительно нужно:
главная трудность — найти, где кончаются различия
<rect x=»60.01″ width=»855.38″ y=»-244.35″ height=»641.13″ style=»stroke-width: 1; stroke: rgb(0, 0, 0); fill: none; «/>
<rect x=»298.43″ width=»340.00″ y=»131.12″ height=»380.00″ style=»stroke-width: 1; stroke: rgb(0, 0, 0); fill: rgb(255, 102, 0); «/>

В чем вы считаете разницу?
1) изменить значение «x» и «width» просто — они идут в одной последовательности
2) как вы думаете, что случилось с id и его значением? как вы хотите это выделить?

Предполагая, что вы всегда знаете, какой из них является «оригинальным»
Я предлагаю вам просканировать «исходную» строку, разметить ее, сопоставить каждый токен отдельно и удалить совпавшие. Только когда вы исчерпали все свои «оригинальные» токены, вы начинаете выделять разницу между «исходным» и «отредактированным».

How to change the color of current line & text selection in eclipse (for Java)?

Aleksandr M's user avatar

In Eclipse Helios : General->Editors->Text Editors : Appearance color options. I always use type filter box in preference widows to check settings.

Eclipse Neon: Preferences > General > Editors > Text Editors — Appearance Color Options / Selection Background Color

I had to spend an inordinate amount of time searching for an answer to this question. Here is a picture of the Preferences from the 2019-03 JavaEE bundle showing which selection is for changing the background color of text you have selected with your mouse in the editor. This is totally different from the Occurrences that people keep pointing out.

enter image description here

John Czukkermann's user avatar

To change the color of current selected line background, follow these steps Eclipse— In Eclipse: go to Windows -> preference-> General -> Editors -> Text Editors ->Appearance color options ->Selection Background Color

To change the color of current selected lines(TEXT), follow these steps Eclipse— In Eclipse: go to Windows -> preference-> General -> Editors -> Text Editors ->Appearance color options ->Selection foreground Color

To change background color of eclipse In Eclipse: go to Windows -> preference-> General -> Editors -> Text Editors ->Appearance color options ->Background Color

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *