Answer the question
In order to leave comments, you need to log in
Java. How to format text in JTextArea and JTextField (change color, font, etc.)?
Can you please tell me everything you know about text formatting in JTextArea and JTextField !
I know that there are methods:
setBackground(Color color) //Changes the background color of the entire field for text
setForeground(Color color) //Changes the color of all text in the field
But these methods change the color of the entire field, but how to change, for example, the color specific letter? And not affect the rest?
How to change the font of a specific letter? How to change the size of a specific letter?
And another question - it is possible to make a section of text inside a JTextArea or JTextField in which the cursor cannot be placed, which cannot be changed: erase, rewrite, etc.
Many thanks and respect in advance :)
Answer the question
In order to leave comments, you need to log in
~^[^az]+~i
Bundled with PHP will be like this
$text = '90+3\' SGDGG p[gdsg] sadgcgbcvb';
echo preg_replace('~^[^a-z]+~i', '', $text);
What template will be for "90+3"? 2 digits, "+", digit? Or everything before "'" (single quote)?
$text = "90+3' SGDGG p[gdsg] sadgcgbcvb";
$result = preg_replace('/^[^\']+\'/', '\'', $text);
$result = str_replace('90+3', '', $text);
To do this, you need to create your own component. You can make this task easier: inherit methods responsible for input and display
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question