Results 1 to 3 of 3
  1. #1
    tfunk92 is offline Member
    Join Date
    Oct 2013
    Rep Power

    Default JList selection to open new window

    I have 2 JLists:
    Java Code:
                                 l1 = new String[]{"Customer Information", "Order Information", "Equiptment Information"}; 
    		 setLayout(new FlowLayout());
    		 list1 = new JList(l1);
    		 list1.setFont (list1.getFont ().deriveFont (16.0f));
    And a JButton:
    Java Code:
    button2 = new JButton("Submit");
    I want to add an ActionListener to open a new window when a certain string is selected in the JList.
    Java Code:
    button2.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e)
                 ///// Enter action here

    Cheers for any help.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: JList selection to open new window

    As always, the API is your best friend: JList (Java Platform SE 7 )

    JList has an addListSelectionListener() method that allows you to add a listener that detects list selection events.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    tfunk92 is offline Member
    Join Date
    Oct 2013
    Rep Power

Similar Threads

  1. file from database...
    By paul78 in forum AWT / Swing
    Replies: 0
    Last Post: 08-07-2012, 09:01 PM
  2. Replies: 4
    Last Post: 01-10-2012, 02:05 PM
  3. Keeping a JOptionPane window open after selection.
    By Joshuak in forum New To Java
    Replies: 1
    Last Post: 12-10-2011, 09:11 AM
  4. Replies: 1
    Last Post: 07-25-2011, 11:24 AM
  5. Replies: 4
    Last Post: 02-07-2011, 09:43 AM

Tags for this Thread

Posting Permissions

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