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 and button is present..

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

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
ModuleNotFoundError: No module named 'google-search-results'
: No module named 'google-search-results' How to remove the ModuleNotFoundError: No module named 'google-search-results' error? Thanks   Hi...ModuleNotFoundError: No module named 'google-search-results'  Hi
ModuleNotFoundError: No module named 'google-search-results'
: No module named 'google-search-results' How to remove the ModuleNotFoundError: No module named 'google-search-results' error? Thanks   Hi...ModuleNotFoundError: No module named 'google-search-results'  Hi
ModuleNotFoundError: No module named 'google-search-results-serpwow'
: No module named 'google-search-results-serpwow' How to remove the ModuleNotFoundError: No module named 'google-search-results-serpwow' error...ModuleNotFoundError: No module named 'google-search-results-serpwow'  
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
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
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
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 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
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
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
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
Developing Search Engine in Java
, and then show you how you can develop your own search engine for your website... in the search engine, the spider search it against the index and retrieves the results... information. ADS_TO_REPLACE_2 The results of a search query is different
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
ModuleNotFoundError: No module named 'odoo8-addon-web-listview-show-advanced-search'
: ModuleNotFoundError: No module named 'odoo8-addon-web-listview-show-advanced-search...-web-listview-show-advanced-search' error? Thanks   Hi... odoo8-addon-web-listview-show-advanced-search python with following command: pip
Search index
Search index  how to write code for advanced search button
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
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
Toggle hide/show by clicking same button
Toggle hide/show by clicking same button In this tutorial, we will discuss about how to toggle hide/show by clicking button. In the given below 2 example, there is button ,by clicking on it, the paragraph will hide/show . In first
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 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
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
how to show hyperlink website on the same page
how to show hyperlink website on the same page  dear sir: i need to know how can you show a webiste on the same page. for example i want to show... on the same page weather it is left aligned or right. i read somewhere that you
search filter and JTable
my question is: how can i make search data in JTable of java? i wan to search... 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
Google Search
Google Search  I have a textbox and submit button in my JSP page. On giving word in the textbox and click submit it should redirct to google search page and fetch all the results based on my input word automatically. JSP/Servlet
Search million records????
Search million records????  How to get fast search results from a table with over 10 million record??? 11g Oracle DB
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
Hibernate Search
Hibernate Search  Where to learn Hibernate Search module? Thanks   Hi, Check the tutorial: Hibernate Search - Complete tutorial on Hibernate Search Thanks
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java... functions. The problem is that how to use binary search array in Java. Please give any online reference show that i will implement the binary search array in Java
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
Form with a search filter in 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...Form with a search filter in spring mvc?  Hi I am new to Spring MVC
Form with a search filter in 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...Form with a search filter in spring mvc?  Hi I am new to Spring MVC
sql query search function
sql query search function  i have a textbox on a form , i like a search a data in the form, when i give whatever name and id or etc..its will search and show the same form , so help me using jsp
How to code a Product id search engine?
How to code a Product id search engine?  I always wonder how people... a search box that let users search products with id. Suppose, "If an user enters id:1234 (and hits search button) go to product page url: http://#" if user
JSF Search - Java Server Faces Questions
JSF Search  Hi, Do you have any examples of how to do a Search programm using JSF in RAD.My Search button should carry the value of the input text field as a parameter and should search in the database for the parameter
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
SEO and Search Engines,Best Search Engines on Web,What is Search Engine
which search engine is most important, how to get indexed in the search etc... the results in the search result page. Best Search EngineADS_TO_REPLACE_2... SEO and Search Engine   
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names

Ads