private void setTextAreaListListener(TextAreaList list) { // add mouseListener to the list list.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { // get the text area item index int index = list.locationToIndex(e.getPoint()); // index cannot be null if (index != -1) { // get the text area item at this index CompIssuesItem item = (CompIssuesItem) list.getModel().getElementAt(index); labelDisplay.setText(item.getId()); list.repaint(); // redraw graphics } } }); }
// writes the text area content to file public boolean writeToTextArea( TextAreaList textAreaList, HashMap<String, ArrayList<Object>> map) { textAreaList.removeAll(); compIssueItems.clear(); CompIssuesItem item; // get data for each record int records = map.get(COL_APP).size(); // had to hard code - used app for (int i = 0; i < records; i++) { String id = ""; String app = ""; String title = ""; String rk = ""; String programmer = ""; String opened = ""; String closed = ""; String version = ""; String description = ""; if (map.get(COL_ID).get(i) != null) id = COL_ID + ": " + map.get(COL_ID).get(i).toString() + " "; if (map.get(COL_APP).get(i) != null) app = COL_APP + ": " + map.get(COL_APP).get(i).toString() + " "; if (map.get(COL_TITLE).get(i) != null) title = COL_TITLE + ": " + map.get(COL_TITLE).get(i).toString() + " "; if (map.get(COL_RK).get(i) != null) rk = COL_RK + ": " + map.get(COL_RK).get(i).toString() + " "; if (map.get(COL_PROGRAMMER).get(i) != null) programmer = COL_PROGRAMMER + ": " + map.get(COL_PROGRAMMER).get(i).toString() + " "; if (map.get(COL_DATE_OPENED).get(i) != null) opened = COL_DATE_OPENED + ": " + map.get(COL_DATE_OPENED).get(i).toString() + " "; if (map.get(COL_DATE_CLOSED).get(i) != null) closed = COL_DATE_CLOSED + ": " + map.get(COL_DATE_CLOSED).get(i).toString() + " "; if (map.get(COL_VERSION).get(i) != null) version = COL_VERSION + ": " + map.get(COL_VERSION).get(i).toString() + " "; if (map.get(COL_DESCRIPTION).get(i) != null) description = COL_DESCRIPTION + ": " + map.get(COL_DESCRIPTION).get(i).toString() + " "; // only show if rk exists if (rk.equals("")) continue; // store information for the item item = new CompIssuesItem(id); /** * print to text area FORMAT * * <p>ID app programmer rank dateOpened dateClosed title * * <p>Description * * <p>--------------------------------------------- */ item.append("\n"); item.append(id + app + programmer + rk + opened + closed + "\n"); item.append(title + "\n"); item.append("\n"); item.append(description + "\n"); // Just appending and let word wrap handle length. // length of the textArea is the length of the issue window text area. item.append("\n"); // a line break between records item.append(HYPHENS + "\n"); compIssueItems.add(item); // only show 10 items // if(compIssueItems.size() == 10) // break; } textAreaList.setListData(compIssueItems.toArray()); return true; }