Can anyone help me with this JList........?

Well have a look at this simple code
I just want to get the item selected in the JList selected to be written in the JTextArea....It compiles ok but when it runs this is the error in the actually JText area......"[Ljava.lang.object,@2611a7]"
What ever that means...I think you'll see from this code........
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
     public class CoffeeMachine extends JFrame {
          private JLabel promptLabel;
          private JList drinkList;
          private JTextArea outputArea;
          private Container container;
          private JButton button1;
          private String drinkNames[] = {"Black Coffee", "White Coffee", "Extra Strong Coffee"};
     public CoffeeMachine()
          super( ":: Please Select a drink ::");
          Container container = getContentPane();
          container.setLayout( new FlowLayout());
          drinkList = new JList( drinkNames );
          promptLabel = new JLabel( "Select a drink from the drop menu (below) ");
          container.add(promptLabel);
          drinkList.setSelectionMode(
          ListSelectionModel. SINGLE_INTERVAL_SELECTION);
               container.add( new JScrollPane( drinkList));
          button1 = new JButton( "OK");
          button1.addActionListener(
     new ActionListener(){
     public void actionPerformed ( ActionEvent event)
     outputArea.setText("Water is boiling your " + drinkList.getSelectedValues() + "please wait");
     container.add( button1 );
     outputArea = new JTextArea (10,20);
     outputArea.setEditable (false);
     container.add(new JScrollPane(outputArea));
     setSize(275, 260 );
     show();
     public static void main( String args[])
     CoffeeMachine application = new CoffeeMachine();
     application.setDefaultCloseOperation(
          JFrame.EXIT_ON_CLOSE);

Sounds like a use for java.util.HashMap.
A HashMap stores key-value -pairs and gives you methods to get and set the value knowing the key. In this case you would have the name of coffee as a key and the object representing the type of the coffee in detail as a value.
Bit like this: import java.util.HashMap;
HashMap coffeeTypes = new HashMap();
CoffeeType blackCoffee = new CoffeeType(NO_MILK);
coffeeTypes.put("Black Coffee", blackCoffee);
CoffeeeType selectedCoffee = (CoffeeeType) coffeeTypes.get("Black Coffee"); Of course instead of literal strings in the example you would use the values you from the list for keys - and you need to define a class that represents a coffee type with the amounts of milk, coffee (different coffee blends..) and water.

Similar Messages

Maybe you are looking for

  • Sending file using FTP

    Hi Friends, I have developed a abap program that download a excel file to a application server. i need to send the file to a shared folder or share point using FTP. How can i send the file which is in Application server thru FTP? Can anybody guide me

  • Maintaining Item Stock Project wise.

    Hi All, I am implementing SBO 2005 B for the Project base company. They get the order & each order is treated as a Project. Now the question is material tracking is required Project wise i.e. which item is available & under which Project. Scenarios a

  • Is it advisable to download platform updates over wireless macbook pro ret?

    Will be downloading update on my brand new....(but, made in mid 2012)....MacBook Pro 15" Retina Display with 10.8.2 version Mountain Lion. Will be only downloading up to 10.8.5....as the new Maverick is conflicting currently with the new ProTools 11

  • WebLogic 12c and OSGi bundles ClassCastException error

    When I deploy an OSGi bundle to WebLogic 12c there are no errors. However, when I try and access my application I get the following error: java.lang.ClassCastException: com.sun.faces.taglib.jsf_core.ViewTag cannot be cast to javax.servlet.jsp.tagext.

  • A (slightly?) DIFFERENT question about the new ActiveX stuff

    http://tinyurl.com/q63d2 Why do you suppose the QuickTime movie here doesn't play even after the click? Works fine in FireFox.