• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Need hlp wit array. plz help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, first of all nice forum. I have a task that i need to perform. I need to create and array which will store medicine when entered in by a user. the code i have so far is:

import javax.swing.JOptionPane;

public class ArrayDemo {
public static void main(String[] args) {
String[] anArray; // declare an array of integers

anArray = new String[10]; // create an array of integers

// assign a value to each array element and print
for (int i=0; i<anArray.length; i++) {
anArray[i] = JOptionPane.showInputDialog("Please enter the medicine"); // setting the element number i
System.out.print(anArray[i] + " "); // showing it
}
System.out.println();
}
}

BUT i need to change it so that when a user enters the medicine a YES_NO_CANCEL_OPTION window appears. i have been playin around wit the code but because i suck at java i jus cant get it. can someone please solve this or advise me please. thanks.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may need to use the JOptionPane.showConfirmDialog method as well as the JOptionPane.showInputDialog method, to get the button set up you require. Check the JOptionPane API entry for your options:

Sun's JOptionPane API entry
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Sorry Jody, I didn't see your response until after I posted.
[ November 17, 2005: Message edited by: Stephen Boston ]
 
Jody Brown
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No harm done, at least we were both on the same train of thought, Steve.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic