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



Home Answers Viewqa Swing-AWT Displaying search results in same panel of gridview in same jframe window.

Have Programming Question? Ask it here!
 
 
 


vikas pandey
Displaying search results in same panel of gridview in same jframe window.
0 Answer(s)      2 years and a month ago
Posted in : Swing AWT


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

Jtable is being constructed dynamically based on columns of database query....

But when we execute search for the second time database table columns are also being added alongwith the search result fields in the dynamically created Jtable Gridview ....

Sir, According to my requirement i need results in the Jtable gridview format in the sam epanel of jframe window .But when i execute second search first search result should be deleted and current search result should be displayed in the jpanel of jframe window....

import java.sql.*; import java.util.*; import java.awt.event.*; import java.lang.String; 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();

    lab.setBounds(10,10,100,20);
    t.setBounds(120,10,100,20);
    b.setBounds(120,40,80,20);
   pane.setBounds(10,90,480,170);
 f.add(lab);
    f.add(t);
    f.add(b);
    f.add(pane);
   f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   pane.setVisible(false);
    f.setSize(600,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/techsoft", "root", "techsoft");
       Statement st=con.createStatement();
       ResultSet rs=st.executeQuery("select * from ankur 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);



        Vector str=columnNames;

         DefaultTableModel model=new DefaultTableModel(data,str);
         table.setModel(model);

         pane.setVisible(true);
        }
        }

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



}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window... search and see the results in the same panel of the Jframe in Gridview Jtable... in the Jtable gridview format in the sam epanel of jframe window .But when i execute
Displaying search results in same panel of gridview in same jframe window.
Displaying search results in same panel of gridview in same jframe window... search and see the results in the same panel of the Jframe in Gridview Jtable... in the Jtable gridview format in the sam epanel of jframe window .But when i execute
Advertisements
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... ,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
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... only current search results alongwith the column as header of gridview
How to open textfields in the the same panel of the jframe by selcting from dropdown menu option ...
the textfields and submit button in the same panel of the jframe window . Below is my code which is displaying textfields in the other jframe. KIndly help me sir...How to open textfields in the the same panel of the jframe by selcting from
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
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
Displaying error on the Same form
Displaying error on the Same form  I want to display the errors on the same form(Top of the form) after validation. I am used Div element and Table.... There is a root Div element they are using for Window purpose. I tried to resize it using DOM
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
Displaying the same image in a JPanel and using scroll - HELP - Java Beginners
Displaying the same image in a JPanel and using scroll - HELP  I hope... JFrame implements ActionListener { private Dimension area; //indicates area...){} private static void createAndShowGUI() { //Create and set up the window
get data in pop up window droplists and on selecting data in the same show a grid table with related datas
get data in pop up window droplists and on selecting data in the same show... a pop up window appears with two drop down lists and a button. One of the drop... on the button I need to get the list of hotels in a table grid format on the same
displaying data based on criteria from 2 tables having same type of data - Java Beginners
displaying data based on criteria from 2 tables having same type of data ... to process search criteria without having a form. I have recently read up about...) to process a search. The search will have following features:- 1
Displaying Error pages in results tree in jmeter
Displaying Error pages in results tree in jmeter   Displaying Error pages in results tree in jmeter
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
Displaying checked checkbox in same page as well as print on another page ....also add next pages cheches checkbox into previous list
Displaying checked checkbox in same page as well as print on another page... same checkboxes. So, from your above code, i can display selected checkbox on same page. It works... But when i go to another page link containing same format
Same day travel deals
Same day travel deals  Hi, Can anyone compare same day travel deals with different travel packages? Thanks
Servlets errors in same page.
Servlets errors in same page.  How do I display errors list in the same page where a form field exists using servlets...........i.e. without using JSP? Please explain with a simple username password program
populating a screen on the same page
populating a screen on the same page  i'm making a time table in jsp. i have put button on each slot.if a person click on that slot it'll redirect to a new page which will help them to choose the subject and faculty through drop
save links clicked in search engine results
save links clicked in search engine results  hello i need to access 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
Two or more actions in the same form
Two or more actions in the same form  Can I have two or more actions in the same form
more Submit buttons in the same form
more Submit buttons in the same form  Can I have two or more Submit buttons in the same form
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
add same tables in jsp page
add same tables in jsp page  hi I have a table in my jsp page with data, now I want to add same copy of table without its default value in same page whenever I click add more table, how do I do
Agra same day car rental
Agra same day car rental  Hi, I want to see the Taj Mahal but just wondering where to book car on rental for the same day trip to Taj Mahal? Thanks
same data inserted 2 times
same data inserted 2 times  thanks for reply, i know the insert command. but same data inserted 2 times.where is the problem i cannot understood
Retrieve all the students in the same year(Java ArrayList)?
in the same year search = null; search...Retrieve all the students in the same year(Java ArrayList)?  FoundStudents.jsp year- parameter I receive from a form search- is an object of type
Same Day Agra Tour
Same Day Agra Tour We are offering Same Day Agra Tour that enables you to see the various tourists attractions in Agra in a single day. The Same Day Agra.... Itinerary for Same Day Agra Tour 0500 Hrs: Pick up from Delhi Hotel 0830 Hrs
Hash value is not same - Java Beginners
Hash value is not same  Hi, I've two Excel files with same data. One is in Excel 2003 (.xls) format and other one is in Excel 2007 (.xlsx) format... 2003 files is not same as the hash value of Excel 2007 file. What might
DOJO+Creating button of same size.
DOJO+Creating button of same size.  I am trying to create two buttons in DOJO of equal size. But the size of the buttons varies depending upon the name of the button that will get displayed. I tried by giving a class atribute
Posting comments to same page with textarea
Posting comments to same page with textarea  I have been given some code which allows a user to type a comment and on submit it will return the text to the same page. Many thanks for that. However I wanted it to add other
how to use a JInternalFrame in a JFrame to create a chat window in a client/server app?
how to use a JInternalFrame in a JFrame to create a chat window in a client/server app?  how to use a JInternalFrame within a JFrame? i want... with JDeskTopPane but i want a chat window which can be moved within the app(just like
Avoiding all the messages shown on the same line
Avoiding all the messages shown on the same line  How to avoid that all the messages are shown on the same line
Using insert update and delete in the same servlet
Using insert update and delete in the same servlet  How to write insert, update and delete coding in the same servlet
to upload a table from DB to the same html page
to upload a table from DB to the same html page  how to make this booklist table to be opened in the same html page itself using a third frame
same thing i want but from db..
same thing i want but from db..  http://www.roseindia.net/tutorial/javascript/dynamicCombo.html same thing i want but from db
Pkg Inheritance under same pkg - Java Beginners
Pkg Inheritance under same pkg   Hi Friends I want to extend the Predefined ( . java File ) class in a another inherited class( .java file ) in the same pkg If this is allowed in the same pkg, please tell me how
local host sharing on same network compute
local host sharing on same network compute  i have an desktop bill application on wamp and i want to use it on other computer on same network . computer connected with hub or switch
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding. For example
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
openning the pdf or doc file in same jsp
openning the pdf or doc file in same jsp   **how to open the pdf and doc file in same jsp after clicking the link or button (which is with out moving to the next page). will some body help me on this @simple format please
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
Redirect to same jsp page on successful login
Redirect to same jsp page on successful login  Hi, I have an application where on successful login, the redirect should happen to same page... from the database. I am unable to create the session for the same login page
how to distinguish engines having same code - Struts
how to distinguish engines having same code  hi we are using struts... introduced a new engine for testing purpose it has almost same code as previous engine... as both access same database .file is kept in central repository both engine
Servlet signup same output - JSP-Servlet
Servlet signup same output  Ok i solved the problem of content type by res.setContentType("text/plain"), but the output is same it always prints the else value(i.e. One of the mandatary field is empty) so please help, thanks
Want to display Arraylist items on same row in JSF
Want to display Arraylist items on same row in JSF  I want do display values of one arraylist on same row using datatable? If i use h:column, then it goes on different row. Please tell me, how I can do it?   Hi Friend
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
Advertisements
 

 

 

DMCA.com