Filter a JTable row with input in a text field

In an enterprise application when there is huge amount data in a table
users feel comfortable if you provide them a option for filtering the
table. Here I show you an example of how to filter a JTable row with
input in a JTextField.

Declare a JTable and your own table model

private MyTableModel tableModel;
private javax.swing.JTable jtblSampleTable;

Now declare a table row sorter for that table model

private TableRowSorter sorter ;

Initialize all the above three declared variables

jtblSampleTable = new javax.swing.JTable();
tableModel = new MyTableModel();
sorter = new TableRowSorter(tableModel);

Bind the model with the table


Set the sorter as the row sorter for the table


Now declare a JTextField

jtfSearch = new javax.swing.JTextField();

Add a document listener for the search text field.

new DocumentListener()
public void changedUpdate(DocumentEvent e)
public void insertUpdate(DocumentEvent e)
public void removeUpdate(DocumentEvent e)

Here is the newFilter method

private void newFilter()
RowFilter< MyTableModel , Object> rf = null;
//declare a row filter for your table model
rf = RowFilter.regexFilter("^" + jtfSearch.getText(), 0);
//initialize with a regular expression
catch (java.util.regex.PatternSyntaxException e)

The above example is able to filter JTable for its first column.

Show video from YouTube in your own website

To show a video from your website, first upload the video in YouTube.
After uploading the vidio add the following code in your website.

<object style="width: 360; height: 250; margin-top: auto; margin-bottom: auto; vertical-align: middle;">

<param name="movie" value=">

<param name="allowFullScreen" value="true"> </param>

<embed src=" type="application/x-shockwave-flash" allowfullscreen="true" width="360" height="250">


In the param tag the value attribute holds the url of your video.
To change the display screen size simply change the width and height attribute
of the embed tag.

This is very simplet just copy and paste the code in your site and test it..

Total Pageviews


Twitter Updates
    follow me on Twitter