Results 1 to 2 of 2
  1. #1
    Antonioj1015 is offline Member
    Join Date
    Oct 2009
    Posts
    4
    Rep Power
    0

    Question How do i show all the values in one window(JOptionPane)??

    I have the following code:
    try
    {
    Class.forName("com.mysql.jdbc.Driver");
    conec = DriverManager.getConnection("jdbc:mysql://localhost/Inventory","root", "");
    est=conec.createStatement();
    res=est.executeQuery("SELECT id_client,name_client,date FROM client");
    while(res.next())
    {
    idClient1=res.getString("id_client");
    NameClient=res.getString("name_client");
    Date1=res.getString("date");
    JOptionPane.showMessageDialog(null, "Document: "+idClient1+"\nName: "+NameClient+"\nDate: "+Date1);
    }}
    catch(ClassNotFoundException e)
    {
    e.printStackTrace();
    }
    catch(SQLException e)
    {
    e.printStackTrace();
    }
    the problem is that it shows the values but i have to click on accept to continue with the next one, How do i show all the values in one window?
    THANKS...

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Create an ArrayList<String> and place the String you generate from the data returned into this list. Then create a String array from this list and show it in the JOptionPane. For instance:
    Java Code:
          String[] strings = {"mon", "tues", "wed", "thurs", "fri"};
          
          List<String> stringList = new ArrayList<String>();
          for (String string : strings) {
             // here you will use instead this:
             // String string = "Document: "+idClient1+"\nName: "+NameClient+"\nDate: "+Date1
             stringList.add(string);
          }
          
          
          String[] stringArray = stringList.toArray(new String[0]);
          JOptionPane.showMessageDialog(null, stringArray);

Similar Threads

  1. HashMap contains all values but doesn't show all values
    By xcallmejudasx in forum New To Java
    Replies: 3
    Last Post: 05-11-2009, 12:35 AM
  2. i want to display decimal values in frame window
    By santhosh_el in forum AWT / Swing
    Replies: 4
    Last Post: 03-16-2009, 10:07 AM
  3. passing values from main page to pop up window
    By vicky in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-29-2008, 04:06 PM
  4. String array for Choice, JOptionPane doesn't show
    By themburu in forum Java Applets
    Replies: 5
    Last Post: 05-29-2008, 02:10 PM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •