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

 
 


vikas pandey
how to show search results in the same panel of jframe to where search field and button is present..
2 Answer(s)      10 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 ........

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 Pages:
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
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 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 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
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 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
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
PHP SQL Search
text  and choose a option from select box. The click on search button helps the user to show the records details based on search text put by the user. Understand with Example  This example illustrates how to create a search
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
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
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
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 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
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
Search index
Search index  how to write code for advanced search button
JSP Servlet Search and Edit - JSP-Servlet
opens in the same location. Can you please show me how that can be achieved? 2..., You can search on the basis of any field but it should be in the form...JSP Servlet Search and Edit  Hi, I want to thank the people who
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
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 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
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
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
need search query - WebSevices
need search query  I have a field in database as DOB. But I want to search recrods as per "fromage" to "toage". I dont know how to compare the ages with DOB field and retrieve records. plese help me.  Hi Friend
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
Search data from database - Java Beginners
with two button search and delete. 2:- User input name(with alphabetical... to user name. (means search all field from database and display using...Search data from database  Hi Deepak, This is not correct code
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 search for string using LIKE operator instead of integer?
how to search for string using LIKE operator instead of integer?  .... and do the same thing by clicking on the hyperlink on itemname column and show... to search for itemid, then it shows "dbtable.jsp" file with 3 columns of itemid
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 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
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... SEO and Search Engine   ... of the search engine while doing SEO work. Since in SEO we are using search
Hibernate Criteria Case Insensitive Search.
Hibernate Criteria Case Insensitive Search.  How to use Case Insensitive Search in Hibernate?   The Case Insensitive ignores the case... it in the same folder where you are going to save your source code. Now create Persistent
search for exact match in excel
search for exact match in excel  How to search for an exact match in excel and show data if the matched sting is found? Please tell me the script. Thanks in Advance
search for exact match in excel
search for exact match in excel  How to search for an exact match in excel and show data if the matched sting is found? Please tell me the script. Thanks in Advance
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
Search word from text file using Java
button = new JButton("Search"); JPanel panel = new JPanel(); panel.add...How to Search word from text file using Java In this section, we are going to search a word from the text file. For this, we have created a swing button
Redirect to Google Search JSP
Redirect to Google Search JSP This tutorial explains you how can you crate a google search in your page. Redircting to google search means the text what you... will give an example of how to provide a google search on your web page
Advance Search in Servlet
Advance Search in Servlet  Sir, I have built an application where... of that string. I'm supposed to show all strings which have that word in them. Ex. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
Advance Search in Servlet  Sir, I have built an application where... of that string. I'm supposed to show all strings which have that word in them. Ex. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
Advance Search in Servlet  Sir, I have built an application where... of that string. I'm supposed to show all strings which have that word in them. Ex. the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
Advance Search in Servlet  Sir, I have built an application where... of that string. I'm supposed to show all strings which have that word in them. Ex. the string typed in is "With regards to the correction in pay" later on in the search
linear search - Java Beginners
linear search  How do i use a linear search for a 2 dimensional hard... and if it's not in the list i need to show an error message to the user.  Hi... { // Search "array" for the specified "key" value public static
Writing to be located through the Search Engine
a search he should immediately know how the page that has opened up connects to his... Writing to be located through the Search Engine       The majority of web users depend upon search

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.