Overriding JList selection behavior

Hi,
I am trying to implement a multiple selection JList that when you right/left click on an item it selects the item, if it is not selected. Deselect the item if it is already selected. The right click works fine, but the left click still works as the default. My code is as follow:
String[] items={ "item 0", "item 1", "item 2", "item 3" , "item 4" };
final JList l = new JList(items);
l.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
l.setUI(new BasicListUI(){
protected MouseInputListener createMouseInputListener()
return new BasicListUI.MouseInputHandler()
{//react on mouse pressed
public void mousePressed(MouseEvent e)
int row = convertYToRow(e.getY() );
if(row >= 0)
{    l.setValueIsAdjusting(true);
if(l.isSelectedIndex(row) )
l.removeSelectionInterval(row,row);
else l.addSelectionInterval(row,row);
public void mouseRelease(MouseEvent e)
l.setValueIsAdjusting(false);
Thanks you.

I'm doing something similar with an inner class of my JList subclass. This code enables toggling and drag-selecting with button 1, and selection clearing with button > 1. Here's the inner class:
class EasySelectListUI extends BasicListUI {
protected MouseInputListener createMouseInputListener() {
return new BasicListUI.MouseInputHandler() {
public void mousePressed(MouseEvent e) {
// clear selection first if button > 1
if (e.getButton() != 1)
clearSelection();
int row = convertYToRow(e.getY());
if (row >= 0) {
setValueIsAdjusting(true);
if (isSelectedIndex(row))
removeSelectionInterval(row, row);
else
addSelectionInterval(row, row);
public void mouseDragged(MouseEvent e) {
// drag select only for button 1
if ((e.getModifiers()&MouseEvent.BUTTON1_MASK) ==0)
return;
int row = convertYToRow(e.getY());
if (row >= 0) {
setValueIsAdjusting(true);
addSelectionInterval(row, row);
public void mouseReleased(MouseEvent e) {
setValueIsAdjusting(false);

Similar Messages

  • Modifying JList selection behavior

    What I want to do is change the selection behavior so that if the user clicks on the left half of the cell, the item is selected, but if the user clicks on the right half, the item is not selected. I already have the code to determine where the user clicked, but can't get the selection to not occur when I determine that the user clicked in the "non-selection area" right half.

    After overriding...
    public void setSelectedIndices(int[] indices)
    public void setSelectedValue(Object anObject, boolean shouldScroll)
    public void setSelectionInterval(int anchor, int lead)
    public void setSelectedIndex(int index)...it worked. I implemented each of these like this.
    public void methodX()
      if( clickOnSelectableRegion )
        super.methodX();
      clickOnSelectableRegion = true;
    }It is the responsibility of an outside MouseListener to determine if the click falls on a selectable region or not. If a click occurs that is not on a selectable region, the listener should call setOnSelectableRegion(false) on the List. I set the value back to true so the listener only has to notify the list of "ignorable" clicks.

  • Overriding JList selection

    Hello,
    I am displaying a JList loaded with Strings inside a scrollpane. I want to make it such that clicking an item selects it, clicking it again unselects it, and multiple items can be selected at any one time. For this I wrote a MouseAdapter
    public class ListListener extends MouseAdapter
      protected JList myList;
      protected String name;
      protected MyFrame parent;
      public ListListener(JList _myList, String _name, MyFrame _parent)
        myList = _myList;
        name = _name;
        parent = _parent;
      public void mouseClicked(MouseEvent e)
        int index = myList.locationToIndex(e.getPoint());
        if(e.getClickCount() == 1)
          parent.ClickItem(index, myList, name);
        else if(e.getClickCount() == 2)
          parent.DoubleClickItem(index, myList, name);
    public class MyFrame extends JFrame
      protected static Vector<Integer> list1onVector = new Vector<Integer>(1, 1);
      protected static Vector<String> list1Vector = new Vector<String>(1, 1);
      protected static JList list1 = new JList();
      public MyFrame()
        //fill list1Vector
        list1.setListData(list1Vector);
        MouseListener list1Clicker = new ListListener(list1, "list1", this);
        list1.addMouseListener(list1Clicker);
      protected void ClickItem(int index, JList myList, String name)
        if(name.equalsIgnoreCase("list1")
          if(list1onVector.contains(Integer.valueOf(index)))
            list1onVector.remove(Integer.valueOf(index));
          else
            list1onVector.add(Integer.valueOf(index));
          inf[] list1Array = new int[list1onVector.size()];
          for(int i = 0; i < list1onVector.size(); i++)
            list1Array = list1onVector.get(i);
          myList.setSelectedIndices(list1Array);
          //do some processing based on what's selected
        else....
    }That seems to work ok... most of the time. Every once in a while however, it will not select an entry or it will make some other entries deselected. Then on next click it shows it how it ought to be. I tried commenting out the code inside mouseClicked and selections were still going on, one at a time. So what I'm guessing is that the built in code that's handling the selections is messing with what I'm trying to do. I tried making my own JList object to deal with it
    public class myJList extends JList
      public myJList()
      public void setSelectionIndex(int index)
        //do nothing here
      public void setSelectedObject(Object anObject, boolean shouldScroll)
        //do nothing here
    }and using that instead of JList, but it didn't help. In fact, doesn't look like it's even going into those functions. What is actually originating the selection even, so I can cut it in the bud? Or is there a better way to do this? Any help is appreciated, thanks.

    Well, I'll be darned, JList is in swing, not sure why i thought it was in awt.
    I made the followowing change to mouseClicked, now looks like this:
    Point point = e.getPoint();
    int clickCount = e.getClickCount();
    SafeClicks doSafeClick = new SafeClicks(myList, name, parent, point, clickCount);
    SwingUtilities.invokeLater(doSafeClick);and ofcourse
    protected class SafeClicks implements Runnable
      protected JList myList;
      protected String name;
      protected JFrame parent;
      protected Point point;
      protected int clickCount;
      public SafeClicks(JList _myList,
      String _name,
      JFrame _parent,
      Point _point,
      int _clickCount)
        myList = _myList;
        name = _name;
        parent = _parent;
        point = _point;
        clickCount = _clickCount;
      public void run()
        int index = myList.locationToIndex(point);
        if(clickCount == 1)
          parent.ClickItem(index, myList, name);
        else if(clickCount == 2)
         parent.DoubleClickItem(index, myList, name);
    }Still the same issue. I think there IS an issue with thread timing and such, but I think the issue is that the JList object (default one) or one of its members is messing with the select at same time I am (and it's an issue if I go first it ends up bad, and if it goes first it ends up good). I think.

  • Overriding Default JTable Selection Behavior

    I'm attempting to override the default selection behavior of a JTable. For clicking, I want the table to behave basically as if the ctrl key was being held down all the time. That works great.
    I want the behavior of dragging a selection to behave a certain way as well. If ctrl is not held down, then a drag should cancel the current selection and start a new one at the drag interval. This works fine too.
    However, if ctrl is held down during a drag, I want the dragged interval to be added to the selection instead of replacing it. This almost works. However, if I hold ctrl while dragging, it no longer let's me "undrag" the selection: once a cell is inside the dragged interval, it's selected, even if you drag back over it to deselect it.
    I understand why that's happening given my approach, but I'm looking for a way around it. Does anybody have any ideas about how to get a JTable to behave the way I want?
    Here's a compilable program that demonstrates what I'm doing:
    import javax.swing.*;
    import java.awt.event.*;
    public class TestTableSelection{
         boolean ctrlDown = false;
         JTable table;
         public TestTableSelection(){
              JFrame frame = new JFrame("Test Table Selection");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //give the table random data
              String [][] data = new String [10][5];
              String [] names = new String [5];
              for(int i = 0; i < 5; i++){
                   names[i] = "C: " + i;
                   for(int j = 0; j < 10; j++){
                        data[j] = "t: " + (int)(Math.random()*100);
              table = new JTable(data, names){
                   //override the default selection behavior
                   public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                        if(ctrlDown){
                             //ctrl + dragging should add the dragged interval to the selection
                             super.changeSelection(rowIndex, columnIndex, toggle, extend);     
                        else{
                             //clicking adds a row to the selection without clearing others
                             //dragging without holding ctrl clears the selection
                             //and starts a new selection at the dragged interval
                             super.changeSelection(rowIndex, columnIndex, !extend, extend);
              //keep track of when ctrl is held down
              table.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent e) {
                        ctrlDown = e.isControlDown();
                   public void keyReleased(KeyEvent e){
                        ctrlDown = e.isControlDown();
              frame.getContentPane().add(new JScrollPane(table));
              frame.setSize(250, 250);
              frame.setVisible(true);
         public static void main(String[] args){
              new TestTableSelection();
    Let me know if any of that isn't clear.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    This change seemed to work for me
              table = new JTable(data, names){
                   int prevRow = -1;
                   //override the default selection behavior
                   public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                        if(ctrlDown){
                             //ctrl + dragging should add the dragged interval to the selection
                             if ( rowIndex != prevRow ) {
                                  prevRow = rowIndex;
                                  super.changeSelection(rowIndex, columnIndex, true, false);
                        else{
                             //clicking adds a row to the selection without clearing others
                             //dragging without holding ctrl clears the selection
                             //and starts a new selection at the dragged interval
                             super.changeSelection(rowIndex, columnIndex, !extend, extend);
              };

  • Limit JTable selection behavior

    I have a simple table with 3 columns an multiple rows. If I select a row with the left mouse button and, with out letting go, move the mouse pointer up to a higher row or down to a lower row the currently selected row changes to the row the mouse pointer is over.
    I need to stop this behavior.
    If I select a row with a left mouse press and move the mouse around when I do a mouse release I want the selected row to still be the one i did the mouse pressed action over.
    Please Help.

    This change seemed to work for me
              table = new JTable(data, names){
                   int prevRow = -1;
                   //override the default selection behavior
                   public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                        if(ctrlDown){
                             //ctrl + dragging should add the dragged interval to the selection
                             if ( rowIndex != prevRow ) {
                                  prevRow = rowIndex;
                                  super.changeSelection(rowIndex, columnIndex, true, false);
                        else{
                             //clicking adds a row to the selection without clearing others
                             //dragging without holding ctrl clears the selection
                             //and starts a new selection at the dragged interval
                             super.changeSelection(rowIndex, columnIndex, !extend, extend);
              };

  • "resolving alias to" message using aliases on 10.6.8 plus slow text-selection behavior

    Recently after no particular change to my Mac Pro3,2 running 10.6.8 other than some routine software updates, whenever I open an alias on my desktop to standard folders or files, a message shows up "Resolving alias to" whatever the alias name and there's a 2-3 second delay before the folder/file opens. I've found discussion of this issue in some archived discussions but never found a comfirmed solution described, so I'm raising this again. As in others' encounter with this behavior, the slow opening of aliases happens (1) only in my own user account, not in a guest account I set up for test purposes [I have no other user accounts than these], and (2) only happens the FIRST time I open an alias. Subsequent uses of the alias work normally.
    Another strange but possibly related behavior that began at the same time as this alias delay is harder to describe but involves a problem when selecting text using mouse clicks or even highlighting with the mouse for editing. For example, to edit the name of a file or folder on my desktop, I would normally click on the file/folder name, pause a moment and click again: this puts me in edit mode with the current file/folder name highlighted/selected. Now when I attempt this procedure, the second time I click immediately opens the file/folder, as though I had double-clicked rather than clicked+paused+clicked. The only way I can select the name of the file/folder to edit it is to click+long pause (like 3 seconds)+click. Then the text is selected as desired. It's as though the clicks are being recognized (by whatever in the OS recognizes clicks) as much faster than actually made.  There is a similar problem in any program I use that permits text editing, whether Word (Office 2011 for Mac), TextEdit, etc. I have to consciously slow down my cursor/click behavior when selecting text. If not, my actions are misinterpreted as double clicks. This text selection behavior also disappears when using a "Guest" user account, only appearing in my own user account. I Using a different mouse has no effect.
    Steps taken so far. I've Repaired Disk Permissions and Verified Disk using Disk Utility, have Safe Booted, and have turned off all login items in my user account,and recently installed the 10.6.8 supplemental update, all to no avail. Any suggestions or has anyone had and solved this/these problems?

    I think my problem has been that in Sytem Preferences>Mouse, my "Double-Click Speed" was set to the SLOWEST setting. After some experimentation, I now have the that setting two notches from the "Fast" end of the scale. In case it's important, the "Primary mouse button" in my Preferences is set to "Left".
    This not only solves the text selection issues described, but also seems to eliminate the strange "resolving alias to" problem.
    [For the curious, I have a Logitech Performance MX wireless mouse which can be configured with "Logitech Control Center". But the LCC software doesn't control double-click speed; this setting can only be made in the Mouse System Preference pane.]

  • How do you turn off the auto select behavior when working with shape layers?

    How do you turn off the auto select behavior when working with shape layers?
    I am using either of the path selection tools to select only some of the paths on the layer. I have the proper layer targeted. I have the selection too auto select option turned off.
    If another layer has a path in that area, that layer becomes auto targeted and I get the wrong path. Turning off the layer is the only way to avoid this but then I have to  turn on the layer back on between making my selection and transforming to use the other layer as guide. Is there any way to stop this auto select? Locking the other layer does not stop the auto select, just prevents editing.

    As far as i know the move tool options don't have any effect on the path selection tools.
    You might try clicking on one of the path points or on the path itself with one of path selection tools and if you want to select multiple points
    you can shift click with the Direct Selection Tool or Alt click to select the entire path.
    more path shortcuts:
    http://help.adobe.com/en_US/photoshop/cs/using/WSDA7A5830-33A2-4fde-AD86-AD9873DF9FB7a.htm l
    http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7391a.h tml

  • JList selection problems

    I'm having problems with JList selection - it's really wierd.
    I have a Jlist and on different selections I want to do stuff - well, I do see the GUI line get highlighted but everytime my ListSelectionListener is called the selected index stays 0.
    also, it always calls the ListSelectionListener twice for every selection I make.
    here's how my code looks:
    (typesList is my JList)
    typesList.setSelectedIndex(0);
    typesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    typesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {       
            int newSelection = typesList.getSelectedIndex(); //this returns always 0!        ...
          }

    Look at the line getValueIsAdjusting... (only one selection is processed. And, this code works and provides proper index.
        * Method to load all Tables from Database user
        public void loadTables() {
            // run Database request
            tableListModel = getListModelData("select object_name from user_objects where object_type = 'TABLE'");
            // now plug List with Model
            tableList = new JList(tableListModel);
            tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            tableList.setSelectedIndex(0);
            //tableList.addListSelectionListener(this);
            tableList.addListSelectionListener(
                new ListSelectionListener() {
                    public void valueChanged( ListSelectionEvent e )
                        if(e.getValueIsAdjusting()) return;
                        String tablename = tableList.getSelectedValue().toString();
                        showColumnData(tablename);
                        displayAllTableData(tablename); //intensive (reworking)
            jScrollPane1.add(tableList);
            jScrollPane1.setViewportView(tableList);
            showColumnData(tableList.getSelectedValue().toString());
        }PiratePete
    http://www.piratepetesoftware.com

  • Disabling List View selection behavior

    Hi,
    I am using List view to display some text rows. I need the scroll bar on the right and the Sort option on top of the list but I would like to disable the selection behavior of each row. I am just using the rows for display purpose but the availability of hand-mouse pointer on each row is misleading as it lets the user to think that some action would be available if they click the mouse on a particular row. So I want to take this hand pointer off. Is there any other alternative to provide display of a table of items with a scroll bar or disable this behavior of List View ? Please help.
    Thanks,
    Veena.

    Hi Veena,
    I guess you are using Xcelsius4.5, right? (Because in X5 there is no hand-mouse point.)
    If you are using X4.5, As I know, hand-mouse point couldn't be disabled and there is no scroll bar for table component. But there maybe a walk-around for list view component:
    1.Set the color of "Mouse Over Text" and "Selected Text" to black or other same color;
    2.Set the color of "Selected Fill" and "Mouse Over Fill" to white.
    Then when mouse over a row or select a row, there will be no color effects.
    If you are using X5, you can set Table's scroll bar property in Behavior tab.
    Best regards

  • JList selection is listened twice

    Hi
    How to make JList selection listener to catch selection events for only one mouse click (mouse pressed or mouse released)

    Hi,
    you are right!
    first time e.getValueIsAdjusting() is true second time
    it is false. It does not corrspond to mousePressed or mouseReleased. I think the first is an item loosing selection and the second is another item getting selection (just a guess).
    Phil

  • How to 'veto' a jList selection change

    Hi All,
    I have a JList which I'm using as a record selector - so whenever my user selects an item on the list, the associated record is loaded up into the other controls on this form for editing. If the user edits any of the data items, I want to ask whether to save changes or not if another item is selected from the JList. So, I've added code in my 'selection changed' function to check for changes and show a 'yes/no/cancel' JOptionPane. The code for my 'yes' and 'no' respones work fine - either save the changes or not, then show the next record. My problem is handling if a user clicks cancel...
    If the user selects 'Cancel', I dont want any of my "show new record" code to execute (this is easy, I can just 'return' out of the function) but also I don't want the JList selection to change. I've tried calling setSelectedIndex() back to the originally selected item, but this in turn triggers my 'selection changed' function to be called again, which causes the user to be asked twice whether they want to save changes!
    So, what I'm after is a kind of beforeSelectionChanged event, which allows the possibility of denying the selection change - but it doesn't look like this exists! I vaguely remember another language (possibly C++/MFC) having this - the user's action could be ignored depending on the return value of the function. Can anyone offer a way of achieving this in Java?
    (It's been a while since I last touched Java, and I'm a complete n00b with Swing. Using NetBeans as my IDE.)
    Thanks in advance for any suggestions!
    Andy

    The way I do it, is to implement a VetoableSelectionModel similar to a bean with a vetoable property: on selection change it queries registered VetoableChangeListeners if they don't object and backs out if one of them barks.
    HTH
    Jeanette

  • Selecting Behavior property of the Call Behavior Action on a UML Activity Diagram

    I have 16 projects in my UML solution, and I need to be able to select a Behavior in the Call Behavior Action property that is in one Activity Diagram, from a list of Activity Diagrams that are located in different projects, but still in the same overall
    Solution.  Currently, it looks like I can only select Behaviors from within the same project.

    This is related to TFS.  I am using Visual Studio 2013, Ultimate.
    It would be more meaningful if I could insert an Activity Diagram into another Activity Diagram, which is similar to what I can do with an Activity Diagram into a Use Case Diagram.  However, TFS will not allow that.  Instead there is the option
    of using the Call Behavior Action.  When I use this item from my toolbox, I can open the Properties for it and select from a list of "Behaviors" (i.e. Activity Diagrams) that are located in the same Project.  I want to select an Activity
    Diagram from a different Project, but still within the same Solution.  Here is a picture:
    These diagrams are all within the same project.  I want to be able to select a diagram from a different project within the same Solution.  For example, select a diagram from Cash Management as the "Behavior" for an item in the Dealer
    License Project.  They are both in the same Solution, so it seems like I should be able to do that.
    Thanks for any advice.
    Jeff
    Jeff

  • How to override Ctrl-Click behavior in Java L&F

    On the Mac, Ctrl-Click is the popup trigger. While Java L&F designers were obviously aware of this (it is warned about in the Java Look and Feel Design Guidelines, 2nd ed, page 106). However, just two pages later (page 108), they then generically specifify that Ctrl-Click is used in lists and tables to toggle the selection.
    The implementation of the Java L&F does not appear to consider the Mac's use of Ctrl-Click and still toggles selection. If there is an additional mouse listener that shows a menu in response to the popup trigger, it will ALSO open the menu on Ctrl-Click.
    What is the best way to overide the Ctrl-Click behavior in JTable etc. to NOT do the toggle selection? Note that this is a mouse event and not a key event, so it can't be turned off or changed by the getActionMap() mechanism.
    Also, does anyone know what the "Command" modifier on the Mac (Command-Click is supposed to toggle selection on Macs) shows up as in the InputEvent (isMetaDown(), isAltGraphDown()...)?

    Try extending the JList and override the processMouseEvent(MouseEvent evt) method and show your popup menu when the user clicks the mouse while holding the CTRL key down. The code below demonstrates the same.
    import java.awt.BorderLayout;
    import java.awt.event.MouseEvent;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.ListModel;
    import javax.swing.WindowConstants;
    public class Temp extends JFrame {
         public Temp() {
              super("Temp");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              String [] items = {"One", "Two", "Three", "Four", "Five"};
              JList list = new MyList(items);
              JScrollPane scroller = new JScrollPane(list);
              getContentPane().add(scroller, BorderLayout.CENTER);
              pack();
              setVisible(true);
         class MyList extends JList {
              public MyList() {
                   super();
              public MyList(Object[] listData) {
                   super(listData);
              public MyList(Vector listData) {
                   super(listData);
              public MyList(ListModel dataModel) {
                   super(dataModel);
              protected void processMouseEvent(MouseEvent evt) {
                   System.out.println(evt.isPopupTrigger());
                   int onmask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
                   if(evt.getModifiersEx() == onmask) {
                        JOptionPane.showMessageDialog(this, "Control + click");
                   else {
                        super.processMouseEvent(evt);
         public static void main(String[] args) {
              new Temp();
    }Hope this helps
    Sai Pullabhotla

  • JList selection issue

    I am stuck again, this time with the behaviour of a JList!
    This is what I am trying to do: I want a selection list, in which any combination of items can be selected. And I want the deselection of a selected item to happen the same way the selection happens- when the user points on the item and clicks the mouse button. It seems that this behaviour is not predefined and multiple selection is only available through use of a key.
    Any ideas how to do this? Easy ways to do it are particularly welcome!
    Thanks a lot!

    If I really wanted this kind of behavior (simple mouse click to select/deselect) I would possibly use an array of JCheckBoxes in a JPanel (in a JScrollPane, if needed) in a GridLayout with one column (or maybe a vertical BoxLayout). To rephrase what E'hic said, introducing non-standard behavior can lead to a non-intuitive user experience.
    Another way could be to use a two column JTable with one Booolean and one String column. Or even only one column holding a custom class containing a boolean and String field, with a custom renderer and editor to show a JCheckBox with appropriate text set.
    Yes, a JList can be tweaked to do what you want, and I'm sure I've seen a solution for this here -- search the forum and you might find something. It's not what I would do, though.
    db

  • How do I get my JList selection to Display after changing

    Granted there are probably 1,000,000,000 ways to write this code. The intent is to have a list of items that are assigned into catagories and when an item is selected the catagories that the item are in are highlighted in the list. This part works OK, as I change items the catagories change to reflect the current item catagories. I have two buttons to add catagories to items and remove catagories from items. The catagory to add is selected from a JCombo drop down list and then the user clicks the addcat button to add the catagory to the item.
    My problem is that the catagories in the JList (that also reside in a JScrollPane) do not show as selected after the list is updated. If I click the addcat button twice then the new catagory is highlighted. I thought that the suggestion in other forum messages to add revalidate and repaint would work so I tried that both at the list and the scrollpane level with no effect.
    -------------- Button Listener code --------------------
    addcat.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    // get the curent catagory from the JCombo..
         String selectedcat = (String) fullcatlist.getSelectedItem();
    // get the curent Item from the JCombo..
         String selecteditem = (String) itemlist.getSelectedItem();
    // add item to catagory
         items.addItemCatagory(selecteditem,selectedcat);
    // debug
         product.setText(selectedcat +"::"+selecteditem);          
         int cnt = 0;
    // get a list of all catagories for this item
         String[] tgtList = catagories.getItemCatagories(selecteditem);
         // debug
         product.setText(selectedcat);          
    // get the JList list
         final ListModel lm = catlist.getModel();
    // get the list size
         int lsize = lm.getSize();
         String st ="";
         for (int j = 0; j < lsize;j++) {
    // get jth element of the list
         st = (String)lm.getElementAt(j);
    // compare it to the selected catagories list in if a match
    // set the index into the selected index array
         for (int k=0;k<tgtList.length;k++) {
         if ( st.compareTo(tgtList[k]) == 0 )
         lst[cnt++]=j;          
    //set up the selections
         int[] ilst = new int[cnt];
         for (int k = 0; k<cnt;k++)
         ilst[k] = lst[k];
    // enable teh selected indice
         catlist.setSelectedIndices(ilst);
    // paint the frame
         scrollPane.revalidate();
         scrollPane.repaint();
    --------------------- end code -----------------

    This might sound sarcastic, but it's not:
    I have no clue how to fix your code, but if your bored and want to try something, try copy-and-pasting that section right afterwards. You'd probably need to change some variables, but, again, I have no clue. This is all just a wild guess. Sorry I couldn't help you any more.

Maybe you are looking for

  • All of my instrument loops from Garage band '09 have disappeared. What do I do?

    All of the insturment loops I have been using have disappeared. They don't show up in new projects, nor are they accessible in old ones that were created using the loops. I have tried to locate the loops on the HD as others have posted but they are n

  • Error in adding datafile in standby databse.

    Hi all. My Environment is as below: Oracle-8.1.7.4.0 OS-HP Unix-11 Primary database (only 1): Production Standby database: Different Machine but same location (HP box) Yesterday I have added 2 datafiles to the two different tablespace. I have checked

  • Email signature editing almost impossible on iOS5 iPhone4

    Anyone else having issues trying to edit signatures on an iPhone 4 in the mail settings? When I try, I can only see a one-line window at the top of the screen, that is almost too close to the top to do any editing. Any suggested resolutions to the is

  • Weblogic Error -  Spring tags

    I'm getting an error when i try to access a page with spring taglibs. During the deploy there are not any error. Error: personAdd.jsp:2:5: No tag library could be found with this URI. Possible causes could be that the URI is incorrect, or that there

  • IPhone won't update from 4.3.1 to 5.0.1

    I have been trying to update my roommates iPhone 3GS software from 4.3.1 to 5.0.1 on iTunes. When I try to click update, a message pops up saying "There was a problem downloading the software for the iPhone. The netwoek connection could not be establ