title: JList: sorting by Up/down buttons
body: <p>Question: Is there an easy way to sort jList using Up/Down Buttons on jFrame? 
  My JList stores path's of image files and displays string with name of the file. I would like to move down/up the element by clicking down/up Button. </p>
  
  <p>Here's what I did - the effect is moving the selection (blue field), not the element. Button2 is button "up". </p>
  
  <pre><code>private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
      int indexOfSelected = jList1.getSelectedIndex();
      File selectedFile = (File) jList1.getSelectedValue();
      indexOfSelected = indexOfSelected - 1;
      jList1.setSelectedIndex(indexOfSelected );
      jList1.updateUI();
  
  }
  </code></pre>
  
  <p>This is how the JList is created:</p>
  
  <pre><code>public void openButtonActionPerformed() {
  
          fc.setMultiSelectionEnabled(true);
          int returnVal = fc.showDialog(null, "Open");
  
           if (returnVal == JFileChooser.APPROVE_OPTION) { 
                 file = fc.getSelectedFiles();
                 len = file.length;
                 System.out.println(len);   
           }    
           for (i=0; i&lt;len; i++){ 
              listModel.add(i, file[i]);
           }
           jList1.setModel(listModel);
           jList1.updateUI();
  }
  </code></pre>
  
  <p>Thank you for your help and patience - in advance. I'm a begginer:)</p>