|
I am writing a search/replace function that is intended to work with Swing JTables which contains Strings. I would like to be able to highlight a substring WITHIN a cell, if that substring is the sought-for value.
For example, if a single cell contained "Now is the time", I would like to be able to highlight "the".
With the following code I can programmatically "select" characters 7-9 of the String:
table.editCellAt(row, col);
DefaultCellEditor ed = (DefaultCellEditor)table.getCellEditor();
JTextField jf = (JTextField)ed.getComponent();
jf.select(7, 10);
However, this does not visibly highlight the text; it merely sets the (invisible) caret to these character positions, so when the user begins to type characters 7-9 are replaced.
|
|
|
|
|
|
|
Suppose you want to know the age of a person given her birth date. Let’s say her birth date is "09-23-1969". Although in this case you might say that we don’t need a program to compute the age, but assuming there are 1000s of records in your database and for every person you have to print a report like:new york investment propertySheila is 29 years old
Fatima is 33 years old
Peter is 17 years old
… and so on
In the database we don’t generally store what the person’s age is — we store business insurance what the person’s date of birth is. This is because given the date of birth, we can always deduct it from today’s date and calculate the number of years that person has lived so far. Calculating date difference also comes handy if you are running phoenix homes for sale a subscription-based website. You need to know for how many days a person has been using your website and when the subscription is due. So in this tip we learn to write a function that returns us the number of days elapsed between two dates. First hsbc credit card the function (I’ll discuss it later on)
|
|
|
|
|
|
|
|