Not able to filter rows of jtable with textfield in netbeans

Not able to filter rows of jtable with textfield in netbeans

DBOperations objDB;
ArrayList alstStock;
public TableRowSorter sorter;
public void viewDailyStock() {
initComponents();
setSize(Toolkit.getDefaultToolkit().getScreenSize());
objDB = new DBOperations();
alstStock = objDB.getStockList();
generateTable();
txtSearch.getDocument().addDocumentListener(
        new DocumentListener() {
    @Override
            public void changedUpdate(DocumentEvent e) {
                newFilter();
            }
    @Override
            public void insertUpdate(DocumentEvent e) {
                newFilter();
            }
    @Override
            public void removeUpdate(DocumentEvent e) {
                newFilter();
            }
        });
setVisible(true);
}
void generateTable() {
Object data[][] = new Object[alstStock.size()][10];
String date = null;
for (int i = 0; i < alstStock.size(); i++) {
    StockBean objBean = (StockBean) alstStock.get(i);
    data[i][0] = i + 1;
    data[i][1] = objBean.getBrand();
    data[i][2] = objBean.getProductCode();
    data[i][3] = objBean.getProductName();
    data[i][8] = objBean.getItemInBox();
    SimpleDateFormat df = new SimpleDateFormat("EEEE, MMM d,yyyy");
    date = df.format(objBean.getDate());
    data[i][4] = date;
    data[i][5] = objBean.getUser();
    data[i][6] = objBean.getLotNumber();
    data[i][7] = objBean.getQtyInItem();
    data[i][9] = objBean.getQtyInBox();
}
String header[] = {"S.No.", "Brand", "Code", "Name", "Date", "Added By", "Lot No.", "Qty In Item", "Item", "Qty In Boxes"};

tblStock = new JTable(data,header);
sorter=new TableRowSorter(tblStock.getModel());
tblStock.setRowSorter(sorter);
jScrollPane1.setViewportView(tblStock);
setWidth();
tblStock.setAutoCreateRowSorter(true);

}
public void newFilter() {
RowFilter rf = null;
try {
    rf = RowFilter.regexFilter(txtSearch.getText(), 3);
} catch (java.util.regex.PatternSyntaxException e) {
    System.out.println("Exception "+e);
}
sorter.setRowFilter(rf);
}

DBOperations is a class for fetching data from database table. StockBean is a class of object with the getter and setter method.

This is my code of implementing row filter to the 4th column of jtable with a textfield but its not working means it is not filtering data and even i am not getting any exception. Please help me...

View Answers









Related Tutorials/Questions & Answers:
Not able to filter rows of jtable with textfield in netbeans
Not able to filter rows of jtable with textfield in netbeans  ... of implementing row filter to the 4th column of jtable with a textfield but its...", "Item", "Qty In Boxes"}; tblStock = new JTable(data,header); sorter=new
Not able to filter rows of jtable with textfield in netbeans
Not able to filter rows of jtable with textfield in netbeans  ... of implementing row filter to the 4th column of jtable with a textfield but its...", "Item", "Qty In Boxes"}; tblStock = new JTable(data,header); sorter=new
Advertisements
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button... not figure out how to. I used DefaultTableModel but wasnt able to insert a row
Not able to display jtable at runtime
Not able to display jtable at runtime  Hello, can anyone please help...[][] taskcells; JTable ttable; public void BuildTable() { Statement st; ResultSet rs...=new JTable(tasktable); TableColumnModel columnModel
search filter and JTable
search filter and JTable  I first im not speak englis very well, so my question is: how can i make search data in JTable of java? i wan to search records in table or textfield but the data display in JTable. Note: i dont
Shading Rows in JTable
Shading Rows in JTable     ... the shading rows in JTable. But, the question arises what is shading?.  Shading Rows: In JTable component the shading rows are the simplest way of shading
Designing of textfield arrays in Netbeans IDE - Swing AWT
Designing of textfield arrays in Netbeans IDE  Respected sir... in NetBeans IDE.... How can i do this.........???? I have a code which... in NetBeans IDE form designing.... public javax.swing.JTextField
Getting the Number of Rows and Columns in JTable
will learn how to get the number of rows and columns in JTable.  This program simply helps us for getting the number of rows and columns from the JTable by using... Getting the Number of Rows and Columns in JTable 
Inserting Rows in a JTable
Inserting Rows in a JTable     ... in a table. This tutorial helps you in how to insert rows in a JTable to specified locations or places according to its field. For inserting a row in JTable component
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
Show multiple identical rows into JTable from database
Show multiple identical rows into JTable from database In this tutorial, you will learn how to display the multiple rows from database to JTable. Here... rows from database on clicking search button to jtable. The given code accepts
Setting the Height and Width of Rows and columns in JTable
Setting the Height and Width of Rows and columns in JTable... in JTable. Earlier, you have read about the JTable that contains the data in rows... we are going to set the height and width of rows and columns in JTable
how to print fasta file into jtable using netbeans IDE
how to print fasta file into jtable using netbeans IDE   mt file... in netbeans IDE. when i click the any row in jtable,particular sequence should... "and"contig00002 length=554 numreads=4" in jtable having three columns
How to show multiple identicle rows from database on clicking search button to jtable
in the jtable .Suppose i enter name in search field which has two rows in the database table so i want to display both or any number of identicle rows in the jtable .I am...How to show multiple identicle rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
in the jtable .Suppose i enter name in search field which has two rows in the database table so i want to display both or any number of identicle rows in the jtable .I am...How to show multiple identicle rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
in the jtable .Suppose i enter name in search field which has two rows in the database table so i want to display both or any number of identicle rows in the jtable .I am...How to show multiple identicle rows from database on clicking search button
jtable
jtable  hi Sir i am working netbeans IDE,I have a jtable when i insert values in jtable then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values then , i am getting output
jtable
jtable  hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
JTable
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable
JTable  Hi I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract...({}); But the tableChanged method is called recursively. And i'm not able
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
jtable
jtable  how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
netbeans
netbeans  guysss m nt able to opemn ma netbeans ide.. no error msg s coming... wn i installed yesterday one msg came stating about some run time error... sm one plzzzzzz hlp me
Create a Custom Cell Renderer in a JTable
that will display in given output of table. The even rows of a JTable contains cyan... Create a Custom Cell Renderer in a JTable       After getting the knowledge about the JTable
NetBeans
NetBeans  why Netbeans IDE is not commonly used Today by most of the companies
JTable
"}; JTable table=new JTable(data,labels); JScrollPane pane=new JScrollPane
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
NetBeans
NetBeans  Hi, I am Kundan I have made a project on NetBeans. And now I want to know that how can i run my project without NetBeans IDE,on other PC. Please help me it's important
NetBeans
NetBeans  Hi, I am Kundan I have made a project on NetBeans. And now I want to know that how can i run my project without NetBeans IDE,on other PC. Please help me it's important
netbeans
netbeans  In netbeans, there are choices of books with their price. you check the book you wanted then click the purchase.the output should be the book with the price then you will get the total price of the book you purchase.how
jtable
jtable  i have build an application and i retrieve data from the database and store it in jtable.now i have to make a checkbox column in each row and also a select all option in header but i am not able to do so.i am getting
filter
filter  What is filter? Can filter be used as request or response
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
TextField
TextField      ... as the TextField. In the example given below, shown a textfield in the applet by creating its...;new TextField("Type in the box");    
TextField validations
TextField validations  I want to know How to check first letter capital or not in a text field and also check all are characters or not in same textfield? and also want to know how to check all digits or not in a textfield? ex
TextField validations
TextField validations  I want to know How to check first letter capital or not in a text field and also check all are characters or not in same textfield? and also want to know how to check all digits or not in a textfield? ex
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container... table after clicking the row on to the jdialog box. i am not able to add
JTable - JDBC
JTable   Hello..... I have Jtable with four rows and columns and i have also entered some records in MsSql database. i want to increase Jtable's rows automatically whenever i have records more than four rows. such as if i have
textfield selected text
textfield selected text  How to select text in text field
jtable problem
jtable problem  how to make a cell text hypertext
Java textfield validaton
Java textfield validaton  Sir... i'm new to java. In java JTextfield when we entered a negative value after pressing one button it have to display an error message dialog of textfield and also the textfield should accept
Java textfield validaton
Java textfield validaton  Sir... i'm new to java. In java JTextfield when we entered a negative value after pressing one button it have to display an error message dialog of textfield and also the textfield should accept
jtable in java swing
jtable in java swing  hai friends... i am creating 1 GUI having 1 table, that table contain 3 fields(columns) and 10 rows.. user can enter values... should reach to 2nd row 1st column. user can not able to edit the values present
JTABLE OF JAVA
JTABLE OF JAVA  i have a jtable in java,i have used checkbox in jtable. now i want to add(submit) only those records that i have checked by checkbox how? i want small example with coding
s:textfield - Struts
s:textfield  I am using the s:textfield tag in an appication and need... this?  Hi friend, Textfield Tag Example Textfield Tag Example

Ads