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

 
 


vikas pandey
Displaying search results in same panel of gridview in same jframe window.
0 Answer(s)      10 months 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);
        }
      }
    });



}

}

View Answers









Related Pages:
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
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 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
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 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
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
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
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
Second Window
a subclass of JFrame (a window) that constructs a JPanel to put the one component... { //====================================================== method main public static void main(String[] args) { JFrame window... (the Java class for a window), which means that it can do everything a JFrame can
JFrame - Window
Java: JFrame - Window Description The javax.swing.JFrame class is used to create a "window". This window has a few characteristics of its own (title... methods JFrame w; // This is the natural Java "window". Container c
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
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
Displaying files on selection of date.
for same.   Here is a java swing code that accepts two dates and search...Displaying files on selection of date.  Hi, I am developing a GUI...); JButton b = new JButton("Search File"); final JTable table=new JTable
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
Chat window
in the same application. I want to know how to retain the chat window (along with the messages) even on navigating to any other page in same application.. i.e.... the chat window pops up.. It is a div in the chat homepage.. There are few other
Tiny Window with subclass
characteristics this.setTitle("Tiny Window using JFrame Subclass... window class. Note 2: This new class is a subclass of JFrame (extends JFrame... Java NotesExample - Tiny Window with subclass This is a reimplementation
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 - Ajax
displaying  hi.. im sending request from ajax page to servlet ..as in response i need the get the from database to servlet and from servlet to ajax in column wise.. i have to display the response column wise in the same
Displaying different portions of a page subsequently on the basis of action
Displaying different portions of a page subsequently on the basis...: with js calender beside these and a SEARCH Button(When the page initially loads). When user clicks the SEARCH button, I want to display another portion along
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
Handling multiple combo boxes of same name - IDE Questions
displaying two combos of same id.. on the browser..if user wants he can...Handling multiple combo boxes of same name  my code is like..... add another subject--> all combos are created with same name & id "csubject
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
setbackground image to JFrame - Java Beginners
setbackground image to JFrame   how to setbackground image to JFrame... TransparentBackgroundImage { public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener( new WindowAdapter() { public
Still have the same problem--First Example of Struts2 - Struts
Still have the same problem--First Example of Struts2  Hi I tried the example in the link. But still I am getting the same problem like as I tried my own example. Its not displaying the "Struts Welcome" message and also
How to display gridview details to labels dynamically?
the gridview results on labels. I used lbDate.Text = GridView1.Rows(0).Cells(0).Text...How to display gridview details to labels dynamically?  I am using SQLDataSource to connect to MySQL. I have a gridview that retrieves information
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
Form with a search filter in spring mvc?
Form with a search filter in spring mvc?  Hi I am new to Spring MVC, I have created a spring project which is displaying the list from database into my jsp page, Now in the same jsp page at the right hand corner I have a search
Form with a search filter in spring mvc?
Form with a search filter in spring mvc?  Hi I am new to Spring MVC, I have created a spring project which is displaying the list from database into my jsp page, Now in the same jsp page at the right hand corner I have a search
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
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want... in the same page inside the corresponding fields in which i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want... in the same page inside the corresponding fields in which i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want... in the same page inside the corresponding fields in which i have entered...-Servlet/9584-JSP-Servlet-Search-and-Edit.html http://www.roseindia.net/jsp
displaying in ajax - Ajax
displaying in ajax  hi.. I have an Ajax page ,request gone to server ana details are bought... the response should be displayed in the same request page not in the other page... Thank u.. I will be waiting
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
opening new window - Java Beginners
; JFrame frame; public A(){ frame=new JFrame(); panel=new JPanel(new... window.i.e., I want to know, how a new window(B) can be opened by clicking a button on the first(parent)window.The show() method does open a new window

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.