I searched for this issue and I found the below codes, but these codes are for Java-Android. What are the similar codes that I can use with Java
The codes are:
ArrayList<Integer> positions = new ArrayList();
Pattern p = Pattern.compile("mp"); // insert your pattern here
Matcher m = p.matcher("Simple Text, bumping , jumping");
while (m.find()) {
positions.add(m.start());
}
Spannable spanning = new SpannableString("Simple Text");
spanning.setSpan(new ForegroundColorSpan(Color.BLUE),positions.get(i), positions.get(i) 1,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(spanning);
CodePudding user response:
Are you using Java Swing?
If yes, you can put "<html>YOUR TEXT</html>"
with needly customizations for you design.
Put it inside an new JLabel("<html>YOUR...");
It is the principle of Java graphics design, and today we have the JavaFX that will replace these method of interface programming
CodePudding user response:
Your soloution. You can change the colour of the label. add this to your jframe or jlabel as you have used in your project. Thank you
Label label = new Label("Your text");
//sets the colour of text
label.setForeground(Color.BLACK);
//sets the backround of text
label.setBackground(Color.BLUE);