/// <summary> /// Creates a list that displays the elements in the specified model. /// </summary> /// <param name="listModel"></param> public G2DList(ListModel listModel) : base() { if (listModel == null) { throw new ArgumentException("listModel has to be non-null value"); } this.listModel = listModel; selectionModel = new DefaultListSelectionModel(); cellRenderer = new DefaultListCellRenderer(); backgroundColor = Color.White; selectionBackgroundColor = Color.SkyBlue; selectionForegroundColor = Color.White; pressedKeys = new List <Keys>(); scrollableTracksViewportHeight = false; scrollableTracksViewportWidth = false; name = "G2DList"; }
private void showJList(JScrollPane view, Point pt) { JList list = (JList)view.Viewport.View; Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, list); int row = list.locationToIndex(p); if (row == -1) { hide(); return; } Rectangle bds = list.getCellBounds(row, row); //GetCellBounds returns a width that is the //full component width; we want only what //the renderer really needs. ListCellRenderer ren = list.CellRenderer; Dimension rendererSize = ren.getListCellRendererComponent(list, list.Model.getElementAt(row), row, false, false).PreferredSize; // fix for possible npe spotted by SCO // http://pspsharp.org/forum/viewtopic.php?p=3387#p3387 if (bds == null) { hide(); return; } bds.width = rendererSize.width; if (!bds.contains(p)) { hide(); return; } //bds.width = rendererSize.width; //if (bds == null || !bds.contains(p)) { // hide(); // return; //} // end "fix for possible npe spotted by SCO" if (setCompAndRow(list, row)) { Rectangle visible = getShowingRect(view); Rectangle[] rects = getRects(bds, visible); if (rects.Length > 0) { ensureOldPopupsHidden(); painter.configure(list.Model.getElementAt(row), view, list, row); showPopups(rects, bds, visible, list, view); } else { hide(); } } }
/// <summary> /// Creates a list that displays the elements in the specified model. /// </summary> /// <param name="listModel"></param> public G2DList(ListModel listModel) : base() { if (listModel == null) throw new ArgumentException("listModel has to be non-null value"); this.listModel = listModel; selectionModel = new DefaultListSelectionModel(); cellRenderer = new DefaultListCellRenderer(); backgroundColor = Color.White; selectionBackgroundColor = Color.SkyBlue; selectionForegroundColor = Color.White; pressedKeys = new List<Keys>(); scrollableTracksViewportHeight = false; scrollableTracksViewportWidth = false; name = "G2DList"; }