codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to highlight text WITHIN a JTable cell?  MarkHausman at 22:27 on Monday, December 08, 2008
 

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.


  Re: How to highlight text WITHIN a JTable cell?  brian500 at 02:10 on Friday, March 12, 2010
 

I am writing a search/replace function that is <a href="http://www.hostseeq.com/business/phoenix-real-estate.htm">phoenix homes for sale</a> 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 only "the".<a href="http://www.hostseeq.com/business/new-york-investment-property.htm">new york investment property</a> With the following code I can programmatically "select" characters 7-9 of the String:

table.<a href="http://www.hostseeq.com/business/business-insurance.htm">business insurance</a> 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 <a href="http://www.hostseeq.com/business/hsbc-card.htm">hsbc credit card</a> characters 7-9 are replaced.

  Re: How to highlight text WITHIN a JTable cell?  brian500 at 02:11 on Friday, March 12, 2010
 

I am writing a search/replace function that is <a href="http://www.hostseeq.com/business/phoenix-real-estate.htm">phoenix homes for sale</a> 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 only "the".<a href="http://www.hostseeq.com/business/new-york-investment-property.htm">new york investment property</a> With the following rope lights
code I can programmatically "select" characters 7-9 of the String:

table.<a href="http://www.hostseeq.com/business/business-insurance.htm">business insurance</a> 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 <a href="http://www.hostseeq.com/business/hsbc-card.htm">hsbc credit card</a> characters 7-9 are replaced.

  Re: How to highlight text WITHIN a JTable cell?  brian500 at 02:56 on Friday, March 12, 2010
 

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)








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Difference between two dates including From & To date
•  Disabe onbeforeunload event?
•  Re: MS Access connection in JSP
•  Re: execute linux commands in perl script
•  Re: Server Name or Address could not be resolved?
•  Re: is null or not an object error
•  Re: Using Crystal Reports for generating dynamic reports in JAVA
•  Re: how to connect asp.net to sql server 2000
•  Re: Dissolve effect for images using Javascript!


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010