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



Home Answers Viewqa Swing-AWT how to show search results in the same panel of jframe to where search field and button is present..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vikas pandey
how to show search results in the same panel of jframe to where search field and button is present..
2 Answer(s)      2 years and 5 months ago
Posted in : Swing AWT


Hello Sir,

Sir i do have one more query ,In the given code search results is being displayed in the other jframe.

But in my application i need to show search results in the same panel of jframe to where search field and button is present .

please Sir, send me the code for that. will always be gratefull. Thanking you nd waiting for reply ........


Advertisement
View Answers

July 12, 2012 at 11:39 AM


Here is a code that search the data from the database and show multiple identical rows from database on clicking search button to jtable.

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

class Search{
    public static void main(String[] args) {
        final Vector columnNames = new Vector();
        final Vector data = new Vector();

        JLabel lab=new JLabel("Enter Name:");
        final JTextField t=new JTextField(20);
        JButton b = new JButton("Search");
        final JTable table=new JTable();
        final JScrollPane pane=new JScrollPane(table);

        JFrame f = new JFrame();
        f.setLayout(null);
        lab.setBounds(10,10,100,20);
        t.setBounds(120,10,100,20);
        b.setBounds(120,40,80,20);
        pane.setBounds(10,70,480,170);
        pane.setVisible(false);
        f.add(lab);
        f.add(t);
        f.add(b);
        f.add(pane);
        pane.setVisible(false);
        f.setSize(500,300);
        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+"'");
           ResultSetMetaData md = rs.getMetaData();
            int columns = md.getColumnCount();
            for (int i = 1; i <= columns; i++){
            columnNames.addElement(md.getColumnName(i) );
            }
            while(rs.next()){
            Vector row = new Vector(columns);
            for (int i = 1; i <= columns; i++){
            row.addElement( rs.getObject(i) );
            }
            data.addElement(row);
           }
           DefaultTableModel model=new DefaultTableModel(data, columnNames);
           table.setModel(model);
           pane.setVisible(true);
            }
            catch(Exception ex){
            System.out.println(e);
            }
          }
        });
    }
}


July 12, 2012 at 12:46 PM


Thank you deepak Thank you very much .Excellent job .

once again thanx ...........



Related Tutorials/Questions & Answers:
how to show search results in the same panel of jframe to where search field and button is present..
how to show search results in the same panel of jframe to where search field... application i need to show search results in the same panel of jframe to where search field and button is present . please Sir, send me the code
how to show search results in the same panel of jframe to where search field and button is present..
how to show search results in the same panel of jframe to where search field... where i have to show the search result in the same panel of where search field and Button is present .I have code which is doing the same work but when i enter
Advertisements
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window.  Hello Sir, I have a search frame window from which we can search and see the results in the same panel of the Jframe in Gridview Jtable
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window.  Hello Sir, I have a search frame window from which we can search and see the results in the same panel of the Jframe in Gridview Jtable
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
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
How to show multiple identicle rows from database on clicking search button to jtable
How to show multiple identicle rows from database on clicking search button to jtable  Hello Sir, I made search button with textfield... and show multiple identical rows from database on clicking search button
How to open textfields in the the same panel of the jframe by selcting from dropdown menu option ...
How to open textfields in the the same panel of the jframe by selcting from... the textfields and submit button in the same panel of the jframe window . Below is my... and i have to show textfields and submit button on the basis of the selection
STRUTS-display search results - Struts
STRUTS-display search results  Hii, I am a beginner in struts..I want to retrieve few records from database and display in jsp page.First i tried... them in jsp.. Search Results
save links clicked in search engine results
search engine results in my program(any search engine).ie suppose i give a keyword,i need the results returned by that search engine.from the returned results... found how to access the search page of search engines(yahoo) from javascript
how to display data from database according to entered value in search field
it to be the same with what i have entered in the search field. let say i entered 17...how to display data from database according to entered value in search... :)   Here is a simple JSP search application where user is allowed to enter
How to search the selected item in row table using radia button in JSP?
How to search the selected item in row table using radia button in JSP?  How to search the selected item in row table using radia button in JSP
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select...' in textbox and click on search button it should show me all the title names
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
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
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my... and cheque number label and textbox to be invisible when by cash radio button is clicked.and they should be visible when by cheque radio button is clicked. I have
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
how to search - WebSevices
how to search  how can I write mysql query for the following search format? Search By:(this have following options)(name,username,email..."); System.out.println("Results"); while( rs.next
Developing Search Engine in Java
, and then show you how you can develop your own search engine for your website..., the spider search it against the index and retrieves the results accordingly. Google.... The results of a search query is different in different search engines just because
How to perform search using AJAX?
and hit button, there is a Ajax call to retrieve search results from a simple txt...How to perform search using AJAX?  Hi, I have following HTML code...; <td><label for="status">Search Status</td> <td><input
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
Search index
Search index  how to write code for advanced search button
enabling parts of a search button based on the ssn boxes filled.
enabling parts of a search button based on the ssn boxes filled.  I want to do an AJAX program to search a particular ssn. Currently I have ssn field with 3 text boxes and a search button to search the particular ssn. I want
How to include website in google search?
How to include website in google search?  Does anyone has idea about how to include a website into Google Search?   Visit the given Google website link on how to oiptimize or submit your website to Google. http
Search bar application
Search bar application In this tutorial, will be creating a Search screen, which have a table view with a search bar. Table should display all the data if search field is empty other wise it should show all the data which matches
multiple records on same panel
multiple records on same panel  i have multiple access of records and i want to display all of them at one panel.Each time a new panel opens for a keyrecord , i want just to show records on same panel or frame, whatever u can
How to search entry in ZipFile.
How to search entry in ZipFile. In this tutorial, We will discuss the use of getEntry() method. The getEntry() methods are available in ZipFile... will search given entry in a zip file. The getEntry method search
Show results in HTML
Show results in HTML  Hi. I have a field in database named stages... as one value, trichy as one value. and i have to show it in html. how to do... for a single record. I have to retrieve these data from the field table. Actually
 

 

 

DMCA.com