title: Java JList formatting vs. functionality of JTable
body: <p>I’m trying to display a listing of patient data in such a way that names are on the left side of my JList and identification numbers are all aligned neatly over to the right. 
  I have looked at and even implemented the use of a JTable for this task as it does provide the neat column structure I’m hoping to achieve in this project but there is some functionality I’m either not aware of how to implement or I feel is lacking in a JTable.</p>
  
  <ol>
  <li><p>The inability to transition my list based on alphanumeric keys. This is a primary way an end user to quickly search through the list as when populated it can be well over 800 rows in length. (example: typing a 's' to transition to the portion of the list starting with 's's)</p></li>
  <li><p>Visually I’m not a fan of row selection with JTables; with a two column structure it is apparent that there is a break between the two columns, unlike with the JList a nice smooth seamless highlighted selection. All grid lines have been turned off as well as the use of cell editing as an FYI.</p></li>
  </ol>
  
  <p>I’ve included what I feel is the relevant code. I’m hoping for some direction on if what I’m asking can be accomplished with a JList or is there a way to better manipulate a JTable? I did not find anything within either the JTable <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html" rel="nofollow noreferrer">API</a> nor the JList <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html" rel="nofollow noreferrer">API</a> I felt answered my question on this.</p>
  
  <pre><code>  package mosaiqToCTWorklist;
  
  import java.awt.Font;
  import java.awt.Label;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
  
  import javax.swing.ButtonGroup;
  import javax.swing.DefaultListModel;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JList;
  import javax.swing.JPanel;
  import javax.swing.JRadioButton;
  import javax.swing.JScrollPane;
  import javax.swing.border.EmptyBorder;
  
  public class PatientSelectionWindow extends JFrame implements ActionListener {
  
      private static final long serialVersionUID = 1L;
      private JPanel contentPane;
      private JRadioButton rdbtnActivePatients;
      private JRadioButton rdbtnInactivePatients;
      private JRadioButton rdbtnAllPatients;
      private JButton btnSendSelection;
      private JList&lt;String&gt; patients;
      private JScrollPane scrollBar;
      private ButtonGroup btngroup;
      private DefaultListModel&lt;String&gt; model = new DefaultListModel&lt;String&gt;();
      private List&lt;PatientData&gt; ptList;
      //  private HashMap&lt;String,PatientData&gt; ptRecords;
      private Label lblPatientTotal;
      private Label lblDOB;
      private Label lblAge;
      private Label lblGender;
      private Label label_4;
  
  
      public PatientSelectionWindow(List&lt;PatientData&gt; ptList) {
          this.ptList = ptList;
          activePatients();
          createWindow();
      }
  
      public void createWindow() {
          setResizable(false);
          setTitle("Mosaiq to CT Worklist");
          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          setBounds(100, 100, 534, 378);
          contentPane = new JPanel();
          contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
          setContentPane(contentPane);
          contentPane.setLayout(null);
  
          patients = new JList&lt;String&gt;(model);
          scrollBar = new JScrollPane(patients);
          scrollBar.setBounds(10, 11, 376, 328);
          scrollBar.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          contentPane.add(scrollBar);
  
          rdbtnActivePatients = new JRadioButton("Active Patients");
          rdbtnActivePatients.addActionListener(this);
          rdbtnActivePatients.setSelected(true);
          rdbtnActivePatients.setFont(new Font("Tahoma", Font.PLAIN, 13));
          rdbtnActivePatients.setBounds(392, 35, 130, 23);
          contentPane.add(rdbtnActivePatients);
  
          rdbtnInactivePatients = new JRadioButton("Inactive Patients");
          rdbtnInactivePatients.addActionListener(this);
          rdbtnInactivePatients.setFont(new Font("Tahoma", Font.PLAIN, 13));
          rdbtnInactivePatients.setBounds(392, 61, 130, 23);
          contentPane.add(rdbtnInactivePatients);
  
          rdbtnAllPatients = new JRadioButton("All Patients");
          rdbtnAllPatients.addActionListener(this);
          rdbtnAllPatients.setFont(new Font("Tahoma", Font.PLAIN, 13));
          rdbtnAllPatients.setBounds(392, 86, 130, 23);
          contentPane.add(rdbtnAllPatients);
  
          btngroup = new ButtonGroup();
          btngroup.add(rdbtnActivePatients);
          btngroup.add(rdbtnInactivePatients);
          btngroup.add(rdbtnAllPatients);
  
          btnSendSelection = new JButton("Send Selected");
          btnSendSelection.addActionListener(new DicomTransfer());
          btnSendSelection.setFont(new Font("Tahoma", Font.PLAIN, 13));
          btnSendSelection.setBounds(396, 154, 126, 38);
          contentPane.add(btnSendSelection);
  
          Label label = new Label("Show");
          label.setFont(new Font("Dialog", Font.BOLD, 11));
          label.setBounds(392, 10, 62, 22);
          contentPane.add(label);
  
          lblPatientTotal = new Label("");
          setPatientCount();
          lblPatientTotal.setBounds(392, 115, 130, 29);
          contentPane.add(lblPatientTotal);
  
          Label label_1 = new Label("D.O.B:");
          label_1.setBounds(396, 252, 38, 22);
          contentPane.add(label_1);
  
          Label label_2 = new Label("Age:");
          label_2.setBounds(396, 226, 30, 22);
          contentPane.add(label_2);
  
          Label label_3 = new Label("Gender:");
          label_3.setBounds(396, 280, 46, 22);
          contentPane.add(label_3);
  
          lblDOB = new Label("1984-10-10");
          lblDOB.setBounds(434, 252, 88, 22);
          contentPane.add(lblDOB);
  
          lblAge = new Label("64");
          lblAge.setBounds(426, 226, 38, 22);
          contentPane.add(lblAge);
  
          lblGender = new Label("male");
          lblGender.setBounds(444, 280, 62, 22);
          contentPane.add(lblGender);
  
          label_4 = new Label("Currently Selected Pt.");
          label_4.setFont(new Font("Dialog", Font.BOLD, 11));
          label_4.setBounds(392, 198, 130, 22);
          contentPane.add(label_4);
      }
  
      private void setPatientCount() {
          Integer patientTotal = model.size();
          lblPatientTotal.setText("Total Patients: " + patientTotal.toString());
      }
  
      private void activePatients() {
          model.clear();
          for(PatientData pt : ptList){
              if (pt.getActiveStatus() == 1) {
                  model.addElement(pt.getLastName() + ", " + pt.getFirstName() + " "
                          + pt.getMiddleName() + " " + pt.getMHN() );
              }
          }
      }
  
      private void inActivePatients() {
          model.clear();
          for(PatientData pt : ptList){
              if (pt.getActiveStatus() == 0) {
                  model.addElement(pt.getLastName() + ", " + pt.getFirstName() + " "
                          + pt.getMiddleName() + " " + pt.getMHN() );
              }
          }
      }
  
      public void allPatients() {
          model.clear();
          for(PatientData pt : ptList){
              model.addElement(pt.getLastName() + ", " + pt.getFirstName() + " "
                      + pt.getMiddleName() + " " + pt.getMHN() );
          }
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
          if (e.getSource() == rdbtnActivePatients) {
              activePatients();
          }
          if (e.getSource() == rdbtnAllPatients) {
              allPatients();
          }
          if (e.getSource() == rdbtnInactivePatients) {
              inActivePatients();
          }
  
          patients.setModel(model);
          setPatientCount();
      }
      }
  </code></pre>
  
  <p>(yes I’m aware I’m using fruit……I’m hungry) Examples of what I get vs what more along the lines of what I was hoping for. It just makes it easier for the end user to read I feel.</p>
  
  <p><img src="https://i.stack.imgur.com/yKW75.png" alt="enter image description here"><img src="https://i.stack.imgur.com/Ps9dJ.png" alt="enter image description here"></p>