Joption acting like it's in a for loop

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

46 Replies - 1609 Views - Last Post: 04 February 2018 - 10:37 AM Rate Topic: -----

#16 Piet Souris  Icon User is offline

  • D.I.C Head

Reputation: 41
  • View blog
  • Posts: 162
  • Joined: 01-December 15

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 04:30 AM

In your short example, to get the focus back to the textfield, and clear the selection, you could try:
@Override
public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {

        JOptionPane pane = new JOptionPane();

        int input = pane.showOptionDialog(searchContactFrame, l_names.getSelectedValue().toString(), "title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
        tf_search.setText("");
        tf_search.requestFocus();
        l_names.clearSelection();
    }
}

Was This Post Helpful? 0
  • +
  • -

#17 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 05:29 AM

One way to alternate actions in the code is increment an int variable and test if its value is even using modulus.
Was This Post Helpful? 0
  • +
  • -

#18 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 7055
  • View blog
  • Posts: 14,734
  • Joined: 16-October 07

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 05:45 AM

First, this is fundamentally disturbing:
public class Test {
    public static class SearchContactGui {
        JFrame searchContactFrame;
        SearchContactGui() {
            searchContactFrame = new JFrame("number book");
            searchContactFrame.setVisible(true);
        }
    }

    public static void main(String[] args) {
        new SearchContactGui();
    }

}



You are using SearchContactGui as essentially a main method. Indeed, you could literally move all your code into main...

In object oriented programming, you create objects. And, like methods, it is betting to have many smaller more focused ones than fewer giant kitchen sink ones. Here, you have a few fairly distinct objects that present themselves.

This is your code with almost no change other than basic clean up:
// these are the only imports you currently use, don't have extra
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import javax.swing.*;

class SearchContact extends JFrame {

    // no JFrame searchContactFrame;
    // do we really, really, need all these as part of the class?
    // private JPanel pnl_top, pnl_topLeft, pnl_topCenter, pnl_left, pnl_search;
    private JList l_names;
    // private JScrollPane scrollPane;
    // private JLabel lbl_searchContact, lbl_search;
    // private JTextField tf_search;
    // private ArrayList<String> matchedNames, matchedNumber, contactsNames;
    private List<String> contactsNames;

    public SearchContact() {
        // searchContactFrame = new JFrame("number book");
        super("number book");
        JPanel pnl_top = new JPanel();

        JLabel lbl_searchContact = new JLabel("Search for Contact");
        lbl_searchContact.setFont(new Font("Arial", Font.BOLD, 25));
        lbl_searchContact.setForeground(Color.blue);
        pnl_top.add(lbl_searchContact, BorderLayout.NORTH);

        JPanel pnl_left = new JPanel();
        pnl_left.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;
        c.gridy = 0;
        JPanel pnl_search = new JPanel();
        JLabel lbl_search = new JLabel("Search");
        JTextField tf_search = new JTextField(18);
        pnl_search.add(lbl_search);
        pnl_search.add(tf_search);
        pnl_left.add(pnl_search, c);
        c.anchor = GridBagConstraints.EAST;
        c.gridx = 0;
        c.gridy = 1;
        c.insets = new Insets(20, 0, 0, 9);

        contactsNames = new ArrayList<>();
        contactsNames.add("bernard");
        contactsNames.add("brandon");
        contactsNames.add("ben");

        Collections.sort(contactsNames);
        l_names = new JList(contactsNames.toArray());
        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setViewportView(l_names);
        scrollPane.setPreferredSize(new Dimension(200, 150));
        pnl_left.add(scrollPane, c);

        add(pnl_top, BorderLayout.NORTH);
        add(pnl_left, BorderLayout.WEST);
        pack();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        tf_search.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {

            }

            @Override
            public void keyPressed(KeyEvent e) {

            }

            @Override
            public void keyReleased(KeyEvent e) {

                if (e.getKeyCode() != KeyEvent.VK_ENTER) {

                    // this is never used matchedNumber = new <String>ArrayList();
                    List<String> matchedNames = new ArrayList<>();

                    for (int j = 0; j < contactsNames.size(); j++) {
                        if (contactsNames.get(j).length() >= tf_search.getText().length()) {

                            if (contactsNames.get(j).substring(0, tf_search.getText().length()).equals(tf_search.getText())) {
                                matchedNames.add(contactsNames.get(j));

                            }
                        }
                    }
                    Collections.sort(matchedNames);
                    // this is kind of nasty, will address soon
                    l_names = new JList(matchedNames.toArray());
                    scrollPane.setViewportView(l_names);

                } else {
                    l_names.requestFocus();
                    l_names.setSelectedIndex(0);

                    /* we'll get back to this
                    l_names.addKeyListener(new KeyListener() {
                        @Override
                        public void keyTyped(KeyEvent e) {

                        }

                        @Override
                        public void keyPressed(KeyEvent e) {

                        }

                        @Override
                        public void keyReleased(KeyEvent e) {
                            if (e.getKeyCode() == KeyEvent.VK_ENTER) {

                                JOptionPane pane = new JOptionPane();

                                int input = pane.showOptionDialog(searchContactFrame, l_names.getSelectedValue().toString(), "title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);

                                //pane.requestFocus();
                            }
                        }

                    });
                     */
                }

            }
        });

    }
}

public class Test {

    public static void main(String[] args) {
        JFrame frm = new SearchContact();
        frm.setVisible(true);
    }

}



Now, with this in mind, perhaps our JList would benefit from being organized into its own class. So:
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;

final class FilteredList extends JList {
    private final String[] allItems;

    public FilteredList(String[] allItems) {
        this.allItems = Arrays.copyOf(allItems, allItems.length);
        Arrays.sort(this.allItems);
        this.filterBy(null);
    }

    public void filterBy(String search) {
        if (search == null || search.length() == 0) {
            this.setListData(allItems);
        } else {
            List<String> matchedNames = new ArrayList<>();
            final int searchLen = search.length();
            for (String item : allItems) {
                //for (int j = 0; j < contactsNames.size(); j++) {
                if (item.length() >= searchLen && item.substring(0, searchLen).equals(search)) {
                    // if (contactsNames.get(j).length() >= tf_search.getText().length()) {
                    // if (contactsNames.get(j).substring(0, tf_search.getText().length()).equals(tf_search.getText())) {
                    // matchedNames.add(contactsNames.get(j));
                    matchedNames.add(item);

                }
            }
            // pointless, the initial list is sorted
            // Collections.sort(matchedNames);
            // no l_names = new JList(matchedNames.toArray());
            this.setListData(matchedNames.toArray());
            // in caller
            // scrollPane.setViewportView(l_names);
        }

    }

}

class SearchContact extends JFrame {

    // no JFrame searchContactFrame;
    // do we really, really, need all these as part of the class?
    // private JPanel pnl_top, pnl_topLeft, pnl_topCenter, pnl_left, pnl_search;
    // private JList l_names;
    private FilteredList filteredList;
    private JScrollPane scrollPane;
    // private JLabel lbl_searchContact, lbl_search;
    private JTextField tf_search;
    // private ArrayList<String> matchedNames, matchedNumber, contactsNames;
    // private List<String> contactsNames;

    public SearchContact() {
        // searchContactFrame = new JFrame("number book");
        super("number book");
        JPanel pnl_top = new JPanel();

        JLabel lbl_searchContact = new JLabel("Search for Contact");
        lbl_searchContact.setFont(new Font("Arial", Font.BOLD, 25));
        lbl_searchContact.setForeground(Color.blue);
        pnl_top.add(lbl_searchContact, BorderLayout.NORTH);

        JPanel pnl_left = new JPanel();
        pnl_left.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;
        c.gridy = 0;
        JPanel pnl_search = new JPanel();
        JLabel lbl_search = new JLabel("Search");
        tf_search = new JTextField(18);
        pnl_search.add(lbl_search);
        pnl_search.add(tf_search);
        pnl_left.add(pnl_search, c);
        c.anchor = GridBagConstraints.EAST;
        c.gridx = 0;
        c.gridy = 1;
        c.insets = new Insets(20, 0, 0, 9);

        filteredList = new FilteredList(new String[] {
            "bernard", "brandon", "ben"
        });
        // contactsNames = new ArrayList<>();
        // contactsNames.add("bernard");
        // contactsNames.add("brandon");
        // contactsNames.add("ben");
        // Collections.sort(contactsNames);
        // l_names = new JList(contactsNames.toArray());
        scrollPane = new JScrollPane();
        scrollPane.setViewportView(filteredList);
        scrollPane.setPreferredSize(new Dimension(200, 150));
        pnl_left.add(scrollPane, c);

        add(pnl_top, BorderLayout.NORTH);
        add(pnl_left, BorderLayout.WEST);
        pack();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // this is fun, gives us access to parent where this won't work
        final SearchContact frm = this;
        tf_search.addKeyListener(new KeyListener() {
            @Override public void keyTyped(KeyEvent e) { }
            @Override public void keyPressed(KeyEvent e) { }
            @Override
            public void keyReleased(KeyEvent e) {
                frm.processSearchKey(e.getKeyCode());
            }
        });
        // hmm, that frm trick might also work for the filterList enter
        filteredList.addKeyListener(new KeyListener() {
            @Override public void keyTyped(KeyEvent e) { }
            @Override public void keyPressed(KeyEvent e) { }
            @Override
            public void keyReleased(KeyEvent e) {
                frm.processFilterKey(e.getKeyCode());
            }
        });
    }
    
    private void processSearchKey(int keyCode) {
        if (keyCode != KeyEvent.VK_ENTER) {
            filteredList.filterBy(tf_search.getText());
            scrollPane.setViewportView(filteredList);

        } else {
            filteredList.requestFocus();
            filteredList.setSelectedIndex(0);
            // now, we don't have to do this every bloody time
            // l_names.addKeyListener(new KeyListener() {
        }
    }
    
    private void processFilterKey(int keyCode) {
        if (keyCode == KeyEvent.VK_ENTER) {
            // JOptionPane pane = new JOptionPane();
            // int input = pane.showOptionDialog(searchContactFrame, l_names.getSelectedValue().toString(), "title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
            JOptionPane.showOptionDialog(this, 
                    filteredList.getSelectedValue().toString(),
                    "title", 
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
        }
        
    }
    
}

public class Test {
    public static void main(String[] args) {
        JFrame frm = new SearchContact();
        frm.setVisible(true);
    }

}



More could be done with this, of course. However, simply using JList.setListData instead of recreating the object every single time probably clears up the problem. Moving the KeyListener work code into clear object level methods is certainly also helpful.

I challenge you do start thinking about the UI components you're using and how you can make them think a little more for themselves and allow for smaller, more focused chunks that will be easier for you to deal with.

Hope this helps.
Was This Post Helpful? 1
  • +
  • -

#19 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 09:00 AM

@baavgai some of your advises were useful, thank you.
About the imports and the class not being in the main well it was from another program just had to make a small example of my problem that's why i copied and removed the file reading and some stuff to make it easier to spot my problem.
But still i have my problem and can't seem to find a good idea to fix it .
Was This Post Helpful? 0
  • +
  • -

#20 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 09:08 AM

Quote

idea to fix it

I found that exiting the listener with the JOptionPane code every other time made the code work like you wanted.
Not a pretty solution, but it is working for me.

This post has been edited by NormR: 22 January 2018 - 09:09 AM

Was This Post Helpful? 0
  • +
  • -

#21 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 09:23 AM

If you mean removing the key listener well it works but then how to add it back when the JOptionPane exit to be able to search for another name.
Was This Post Helpful? 0
  • +
  • -

#22 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 09:30 AM

Add a line of code in the listener that exits every other time. For example:
  if(cntr++ % 2 == 0)  return;  // exit when counter is even

Was This Post Helpful? 0
  • +
  • -

#23 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 09:56 AM

well it worked but on the second time i get a null pointer exeption on the lane that has the JOptionPane.showOptionDialog
Was This Post Helpful? 0
  • +
  • -

#24 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:07 AM

Quote

i get a null pointer exeption

What variable has the null value?

Please copy the full text of the error message and paste it here.

Also post all of the new code.
Was This Post Helpful? 0
  • +
  • -

#25 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:30 AM

package test;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.*;

/**
 *
 * @author ViSion
 */
public class Test {

    public static class SearchContactGui {

        JFrame searchContactFrame;
        JPanel pnl_top, pnl_topLeft, pnl_topCenter, pnl_left, pnl_search;
        JList l_names;
        JScrollPane scrollPane;
        JLabel lbl_searchContact, lbl_search;
        JTextField tf_search;
        ArrayList<String> matchedNames, matchedNumber, contactsNames;
        KeyListener key;
        JOptionPane pane = new JOptionPane();
        int cntr = 1;

        SearchContactGui() {

            searchContactFrame = new JFrame("number book");
            pnl_top = new JPanel();

            lbl_searchContact = new JLabel("Search for Contact");
            lbl_searchContact.setFont(new Font("Arial", Font.BOLD, 25));
            lbl_searchContact.setForeground(Color.blue);
            pnl_top.add(lbl_searchContact, BorderLayout.NORTH);

            pnl_left = new JPanel();
            pnl_left.setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();
            c.gridx = 0;
            c.gridy = 0;
            pnl_search = new JPanel();
            lbl_search = new JLabel("Search");
            tf_search = new JTextField(18);
            pnl_search.add(lbl_search);
            pnl_search.add(tf_search);
            pnl_left.add(pnl_search, c);
            c.anchor = GridBagConstraints.EAST;
            c.gridx = 0;
            c.gridy = 1;
            c.insets = new Insets(20, 0, 0, 9);

            contactsNames = new ArrayList<String>();
            contactsNames.add("bernard");
            contactsNames.add("brandon");
            contactsNames.add("ben");

            Collections.sort(contactsNames);
            l_names = new JList(contactsNames.toArray());
            scrollPane = new JScrollPane();
            scrollPane.setViewportView(l_names);
            scrollPane.setPreferredSize(new Dimension(200, 150));
            pnl_left.add(scrollPane, c);

            searchContactFrame.add(pnl_top, BorderLayout.NORTH);
            searchContactFrame.add(pnl_left, BorderLayout.WEST);
            searchContactFrame.pack();
            searchContactFrame.setVisible(true);
            searchContactFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            tf_search.addKeyListener(key = new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {

                }

                @Override
                public void keyPressed(KeyEvent e) {

                }

                @Override
                public void keyReleased(KeyEvent e) {

                    if (cntr++ % 2 != 0) {
                        return;
                    }
                    if (e.getKeyCode() != KeyEvent.VK_ENTER) {

                        matchedNumber = new <String>ArrayList();
                        matchedNames = new <String>ArrayList();

                        for (int j = 0; j < contactsNames.size(); j++) {
                            if (contactsNames.get(j).length() >= tf_search.getText().length()) {

                                if (contactsNames.get(j).substring(0, tf_search.getText().length()).equals(tf_search.getText())) {
                                    matchedNames.add(contactsNames.get(j));

                                }
                            }
                        }
                        Collections.sort(matchedNames);
                        l_names = new JList(matchedNames.toArray());
                        scrollPane.setViewportView(l_names);

                    } else {
                        l_names.requestFocus();
                        l_names.setSelectedIndex(0);

                        l_names.addKeyListener(new KeyListener() {
                            @Override
                            public void keyTyped(KeyEvent e) {

                            }

                            @Override
                            public void keyPressed(KeyEvent e) {
                                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
JOptionPane pane = new JOptionPane();
                                    
                                int    input = pane.showOptionDialog(searchContactFrame, l_names.getSelectedValue().toString(), "title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);

                                    if (input == JOptionPane.OK_OPTION) {

                                        System.out.println("ok");
                                        l_names.clearSelection();
                                        tf_search.requestFocus();
                                    }
                                }
                            }

                            @Override
                            public void keyReleased(KeyEvent e) {

                                //pane.requestFocus();
                            }

                        });
                    }

                }
            });

        }
    }

    public static void main(String[] args) {
        new SearchContactGui();
    }

}



Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at test.Test$SearchContactGui$1$1.keyPressed(Test.java:136)
	at java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:250)
	at java.awt.Component.processKeyEvent(Component.java:6491)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
	at java.awt.Component.processEvent(Component.java:6310)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
	at java.awt.Component.dispatchEventImpl(Component.java:4760)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.window.dispatchEventImpl(window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Picked up _JAVA_OPTIONS: -Xmx256M

Was This Post Helpful? 0
  • +
  • -

#26 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:34 AM

What variable has the null value?

The cntr code is in the wrong method. It is supposed to be in the method with the JOptionPane code.

This post has been edited by NormR: 22 January 2018 - 10:37 AM

Was This Post Helpful? 0
  • +
  • -

#27 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:50 AM

well i'm not sure but it works fine were i place it the null pointer exception is on the lane containing
int    input = pane.showOptionDialog(searchContactFrame, l_names.getSelectedValue().toString(), "title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);


looks like the l_names.getSelectedValue() is null.

This post has been edited by ViSion91: 22 January 2018 - 10:51 AM

Was This Post Helpful? 0
  • +
  • -

#28 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:52 AM

Quote

looks like the l_names.getSelectedValue() is null.

Is that caused by line 141 that clears the selection?
Was This Post Helpful? 0
  • +
  • -

#29 ViSion91  Icon User is online

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:55 AM

yeah i'm pretty sure that's what causing it.
Was This Post Helpful? 0
  • +
  • -

#30 NormR  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 658
  • View blog
  • Posts: 4,964
  • Joined: 25-December 13

Re: Joption acting like it's in a for loop

Posted 22 January 2018 - 10:57 AM

What should the code do if there isn't a selected item in the list?
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4