1 Reply Latest reply: Dec 18, 2011 1:19 PM by DarrylBurke RSS

    help with ScrollPane

    REDO LOG
      Hi all



      I am about building a java desktop application that query a database and show the results

      the results are stoked in a jtable, to show the results, i did the following :

      //tabledb: an instance of a class that execute the query and save the results in a jtable named donnee (tabledb.donnee, donnee is a field in the class retrieving data )


      JScrollPane jScrollPane2 = new JScrollPane(tabledb.donnee);
      JPanel buttonPanel = new JPanel();

      JFrame fr = new JFrame();

      fr.getContentPane().add( buttonPanel, BorderLayout.SOUTH );

      fr.getContentPane().add(jScrollPane2);

      fr.pack();

      fr.setVisible(true);


      its works fine, but now I am trying to show in the frame where i have entered the query: ie i dont wont to create another jframe to show the table of results

      I tried this :


      jScrollPane2.add(tabledb.donnee); //jScollPane2 is declared before, actually I am working with swing framework where I can drag and drop component (jScollPane2 is draged
      // and droped into the main frame



      JPanel buttonPanel = new JPanel();



      this.getContentPane().add( buttonPanel, BorderLayout.SOUTH );

      this.getContentPane().add(jScrollPane2);

      this.pack();

      this.setVisible(true);



      but when i run the application i issued a query and no changes in the jScollPane2, no results



      did i miss something or I have problem in my conception??

      thanks in advance

      regards rachid