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



Home Answers Viewqa Java-Beginners search filter and JTable

Have Programming Question? Ask it here!
 
 
 


joel marroquim
search filter and JTable
3 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners


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 have a table.

PLEASE HELP.... THANKS


Advertisement
View Answers

April 2, 2012 at 3:10 PM


import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;

class Search{
    public static void main(String[] args) {
        JLabel lab=new JLabel("Enter Name:");
        final JTextField t=new JTextField(20);
        JButton b = new JButton("Search");
        JPanel p = new JPanel(new GridLayout(2,2));
        p.add(lab);
        p.add(t);
        p.add(b);
        JFrame f = new JFrame();
        f.getContentPane().add(p);
        f.pack();
        f.setVisible(true);

        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            String name=t.getText();
            try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from data where name='"+name+"'");
           String n="",add="",contact="",email="";

           if(rs.next()){
               n=rs.getString("name");
                add=rs.getString("address");
                contact=rs.getString("contactNo");
                email=rs.getString("email");
           }
           String data[][]=new String[1][4];
           data[0][0]=n;
           data[0][1]=add;
           data[0][2]=contact;
           data[0][3]=email;
           JFrame frame=new JFrame();
           String labels[]={"Name","Address","Contact No","Email"};
           JTable table=new JTable(data,labels);
           JScrollPane pane=new JScrollPane(table);

            frame.add(pane);
            frame.setVisible(true);
            frame.pack();

            }
            catch(Exception ex){
            System.out.println(e);
            }
            }
        });
    }
}


April 2, 2012 at 10:50 PM


thanks for you answer, now I can see by the code in my project ...



April 3, 2012 at 12:57 AM


Thanks I managed to enter the code in my project so give me this error when I call my button, for example in another package a class called desktopapplication i have an interface that runs on my table this in mysql, so I do not interface desktopapplication I have a button called search, but the button is called I put the code:

search demo = new search (); demo.actionPerformed (evt);

but he did not recognize that the action perfomed. because it will be???

tou asking for your help once again .................



Related Tutorials/Questions & Answers:
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
Form with a search filter in spring mvc?
Form with a search filter in spring mvc?  Hi I am new to Spring MVC... into my jsp page, Now in the same jsp page at the right hand corner I have a search filter where I need to search by transaction id which is one of the field
Advertisements
Form with a search filter in spring mvc?
Form with a search filter in spring mvc?  Hi I am new to Spring MVC... into my jsp page, Now in the same jsp page at the right hand corner I have a search filter where I need to search by transaction id which is one of the field
jtable displays search results
jtable displays search results   hi sir can u send me full source code for displaying search results into jtable from database n jtable n search button must be within same frame but in different Panel and the size of the frame
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
filter
filter  What is filter? Can filter be used as request or response
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
javax.swing.*; class Search{ public static void main(String[] args... JTextField(20); JButton b = new JButton("Search"); JPanel p = new..."}; JTable table=new JTable(data,labels); JScrollPane pane=new JScrollPane
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...How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield
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...How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield
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...How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield
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
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  Hi I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract method tableChanged(TableModelEvent e) . I'll be loading values from data base when
Filter/Controller
Filter/Controller  what is the difference b/w org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter... one is filer. I have confusion with these two. Is there any d/f b/w filter
security filter
security filter  i have included WebFilter.java in my application. i am getting this error . error 500:filter[WebFilter]: filter unavailable. whats the reason for this error
JSF+Filter
JSF+Filter  What is the meaning of the tags: avoid-urls for filter configurations in web.xml.
JTABLE Issue
on Swing-AWT. I have used JTABLE to show data. There is "input field" and "search... frame which gets open on click of search button. this JTable also has a back button... for eg. Customer's name and click to search button data comes on JTable according
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
JTable - Java Beginners
JTable Search Filter  Hi,i wanted to add a search filter in my JTable application.Thanks in Advance!!  i'means using database access,when...=============================================================================i press the enter button into JTable cell and focus
Search
Search   Hi, I have a project in which I am trying to enter "Marathi" (Indian local language) data in JSP using JSTL and trying to search data... and tries to search then It shows no data from database
esign filter for wifi router
esign filter for wifi router  How can i make a filter for my wifi router to filter packets from specific ip or mac address
JTable - Java Beginners
JTable search example  I've problem about JTable, i wan to search records when i types words in JTable cell,can u give the source code.I'm Beginner and i start begins learning java programming.Please send the example into my
filter implementation in java
filter implementation in java   How to implement filters in java?   Java - filter implementation Tutorials Filter Files in Java Response Filter Servlet Example
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... { JFrame f; JPanel p; JLabel l; JTextField tf; JButton btn; JTable tb
jtable problem
jtable problem  how to make a cell text hypertext
ISAPI Filter Error (
ISAPI Filter Error (  MFC: For ISAPI Filter geting error from Web service i.e ("Error:- InternetOpenUrl()") I have writen MFC application for ISAPI filter which will authenticate and authorization the request. Its working fine
Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked
Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked  Can anybody say the Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked
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
Jtable-Java
Jtable-Java  Hi all,I have a Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
java jtable
java jtable  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to read only... that in jtable. plz help me with the code
jtable query
jtable query  I need a syntax...where i could fetch the whole data from the database once i click the cell in jtable...and that must be displayed in the nearby text field which i have set in the same frame
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... a container on the jtable. kindly help me sir. thanks in advance regards, rajahari
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
Servlet Filter
Servlet Filter In this tutorial you will learn about the Filter. A filter... are done by the Filter. Some of the main tasks are as follows : Restrict... and performs tasks accordingly. Filter can be used in such areas where
Struts2 Filter not getting initialised in WAS 8.0
Struts2 Filter not getting initialised in WAS 8.0  Hi All, Am facing... "Struts2 filter could not be initialised" The filter properties are set... Application</display-name> <filter> <filter-name>struts2</filter
Uses of JQuery filter
Uses of JQuery filter       Uses of JQuery filter The jQuery filter is used to filter out certain values from the object list based on certain criterion
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
JTable duplicate values in row
JTable duplicate values in row  JTable duplicate values in row
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
Visibility Filter
Visibility Filter       Visibility Filter This filter filters the element according to their visibility. Means it filters by either hidden or  visible : hidden
 

 

 

DMCA.com