Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Not able to filter rows of jtable with textfield in netbeans
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Kapil Jindal
Not able to filter rows of jtable with textfield in netbeans
0 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners


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...


Advertisement
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
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
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
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
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
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
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
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
filter
filter  What is filter? Can filter be used as request or response
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
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... to set the height and width of rows and columns in JTable. This table has
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
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
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
NetBeans
NetBeans  why Netbeans IDE is not commonly used Today by most of the companies
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.... And i'm not able to set value to a particular column. How can i do it? Please
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  Values to be displayed in JTextfield when Clicked on JTable Cells
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  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
Advertisements
 

 

 

DMCA.com