Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2009, 05:05 PM
Member
 
Join Date: Oct 2009
Posts: 4
Rep Power: 0
Antonioj1015 is on a distinguished road
Question How do i show all the values in one window(JOptionPane)??
I have the following code:
Quote:
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...
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-25-2009, 05:17 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 5,968
Rep Power: 7
Fubarable is on a distinguished road
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:
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);
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +2. The time now is 07:04 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org