< prev index next >

## src/com/sun/javatest/audit/ListPane.java

Print this page

      44         model = new ListModel();
      45         list = uif.createList(uiKey + ".lst", model);
      46         list.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
      47         list.setCellRenderer(new Renderer());
      48
      49         JScrollPane sp = uif.createScrollPane(list,
      50                                          JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      51                                          JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      52         setBody(sp);
      53     }
      54
      55     void setData(Object[] data) {
      56         if (data == null || data.length == 0)
      57             show(uif.getI18NString("list.noEntries"));
      58         else {
      59             model.setData(data);
      60             showBody();
      61         }
      62     }
      63
      64     private class ListModel extends AbstractListModel {
      65         public Object getElementAt(int index) {
      66             return data[index];
      67         }
      68
      69         public int getSize() {
      70             return (data == null ? 0 : data.length);
      71         }
      72
      73         void setData(Object[] data) {
      74             this.data = data;
      75             fireContentsChanged(this, 0, data.length - 1);
      76         }
      77
      78         private Object[] data;
      79     }
      80
      81     private class Renderer extends DefaultListCellRenderer {
      82         public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
      83             String name;
      84             if (o instanceof TestResult) {
      85                 TestResult tr = (TestResult) o;
      86                 name = tr.getTestName();
      87             }
      88             else if (o instanceof TestDescription) {
      89                 TestDescription td = (TestDescription) o;
      90                 name = td.getRootRelativeURL();
      91             }
      92             else
      93                 name = String.valueOf(o);
      94             return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
      95         }
      96     }
      97
      98     protected JList list;
      99     private ListModel model;
     100 }
      44         model = new ListModel();
      45         list = uif.createList(uiKey + ".lst", model);
      46         list.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
      47         list.setCellRenderer(new Renderer());
      48
      49         JScrollPane sp = uif.createScrollPane(list,
      50                                          JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      51                                          JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      52         setBody(sp);
      53     }
      54
      55     void setData(Object[] data) {
      56         if (data == null || data.length == 0)
      57             show(uif.getI18NString("list.noEntries"));
      58         else {
      59             model.setData(data);
      60             showBody();
      61         }
      62     }
      63
      64     private class ListModel extends AbstractListModel<Object> {
      65         public Object getElementAt(int index) {
      66             return data[index];
      67         }
      68
      69         public int getSize() {
      70             return (data == null ? 0 : data.length);
      71         }
      72
      73         void setData(Object[] data) {
      74             this.data = data;
      75             fireContentsChanged(this, 0, data.length - 1);
      76         }
      77
      78         private Object[] data;
      79     }
      80
      81     private class Renderer extends DefaultListCellRenderer {
      82         public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
      83             String name;
      84             if (o instanceof TestResult) {
      85                 TestResult tr = (TestResult) o;
      86                 name = tr.getTestName();
      87             }
      88             else if (o instanceof TestDescription) {
      89                 TestDescription td = (TestDescription) o;
      90                 name = td.getRootRelativeURL();
      91             }
      92             else
      93                 name = String.valueOf(o);
      94             return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
      95         }
      96     }
      97
      98     protected JList<Object> list;
      99     private ListModel model;
     100 }

< prev index next >