📄 list.java
字号:
return ip.getBackground();}ClassProperties getClassProperties () { return ClassAnalyzer.analyzeAll( getClass(), true);}public Color getForeground () { // some anomaly, we forward colors to our ip, so we should return its colors // for consistencies sake return ip.getForeground();}public String getItem ( int index) { return (String)ip.rows.elementAt( index);}public int getItemCount () { return (countItems());}public synchronized String[] getItems () { String[] si = new String[ ip.rows.size() ]; for ( int i=0; i<si.length; i++) { si[i] = (String)ip.rows.elementAt( i); } return si;}public int getRows () { return ip.rows.size();}public synchronized int getSelectedIndex () { return sel;}public synchronized int[] getSelectedIndexes () { int[] r; int i, j, n; if ( multipleMode ) { if ( nSel == 0 ) return new int[0]; else if ( (nSel == 1) && (sel >= 0) ){ r = new int[1]; r[0] = sel; return r; } else { r = new int[nSel]; n = Math.min( ip.rows.size(), multiSel.size()); for ( i=0, j=0; i<n; i++ ) { if ( multiSel.get( i) ){ r[j++] = i; if ( j == nSel ) break; } } return r; } } else { if ( sel >= 0 ) { r = new int[1]; r[0] = sel; return r; } else { return new int[0]; } }}public synchronized String getSelectedItem () { if ( sel >= 0 ) { return (String) ip.rows.elementAt( sel); } else if ( nSel > 0 ) { int n = Math.min( multiSel.size(), ip.rows.size()); int i; for ( i=0; i<n; i++ ){ if ( multiSel.get(i) ) return (String) ip.rows.elementAt( i); } } return null;}public synchronized String[] getSelectedItems () { // Not very nice to copy this from getSelectedIndexes, but some people // don't care how many items they have in their lists, and creating this // from a temporary int[] might produce a lot of garbage. Moreover, some // people just don't care for if they are in multiMode and use this // as a default (i.e. also in single mode) String[] r; int i, j, n; if ( multipleMode ) { if ( nSel == 0 ) return new String[0]; else if ( (nSel == 1) && (sel >= 0) ){ r = new String[1]; r[0] = (String) ip.rows.elementAt( sel); return r; } else { r = new String[nSel]; n = Math.min( ip.rows.size(), multiSel.size()); for ( i=0, j=0; i<n; i++ ) { if ( multiSel.get( i) ){ r[j++] = (String) ip.rows.elementAt( i); if ( j == nSel ) break; } } return r; } } else { if ( sel >= 0 ) { r = new String[1]; r[0] = (String) ip.rows.elementAt( sel); return r; } else { return new String[0]; } }}public Object[] getSelectedObjects () { // Now what is this - we can't put arbitrary Objects in there, but we can get // them out? Seems like somebody finally discovered the potential of Lists, // but didn't finish on it. // Since we don't consider this the default access method (unfortunately), we // don't do the same expensive processing like in getSelectedItems int i; int[] selIdx = getSelectedIndexes(); Object[] selObj = new Object[selIdx.length]; for ( i=0; i<selIdx.length; i++ ) { selObj[i] = ip.rows.elementAt( selIdx[i]); } return selObj;}public int getVisibleIndex () { return ip.first;}void hPosChange () { ip.repaint();}public boolean isIndexSelected ( int index) { return (isSelected(index));}public boolean isMultipleMode () { return (allowsMultipleSelections());}/** * @deprecated */public boolean isSelected ( int index ) { if ( sel == index ) return true; if ( multipleMode ) return multiSel.get( index); return false;}public void makeVisible ( int idx ) { ip.makeVisible( idx);}public Dimension minimumSize () { return minimumSize(0);}public Dimension minimumSize (int rows) { return preferredSize(rows);}void notifyAction () { String s = (sel >= 0) ? (String) ip.rows.elementAt( sel) : null; if ( (s != null) && ((aListener != null) || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0) ) { Toolkit.eventQueue.postEvent( ActionEvt.getEvent( this, ActionEvent.ACTION_PERFORMED, s, 0)); }}void notifyItem ( Object item, int op) { if ( (iListener != null) || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 || (flags & IS_OLD_EVENT) != 0 ){ ItemEvt e = ItemEvt.getEvent( this, ItemEvent.ITEM_STATE_CHANGED, item, op); Toolkit.eventQueue.postEvent( e); }}public void paint ( Graphics g ) { // we know about our childs, we don't have to blank the background, // so let's speed up things a little g.paintChild( ip, false); if ( (ip.hScroll != null) && ((ip.hScroll.flags & IS_VISIBLE) != 0) ) g.paintChild( ip.hScroll, true); if ( (ip.vScroll != null) && ((ip.vScroll.flags & IS_VISIBLE) != 0) ) g.paintChild( ip.vScroll, true);}protected String paramString() { return super.paramString();}public Dimension preferredSize () { int rows = ip.rows.size(); if ( rows < 5 ) rows = 5; else if ( rows > 10 ) rows = 10; return preferredSize( rows);}public Dimension preferredSize (int rows) { int h = rows * ip.rowHeight; int w = 25 * ip.fm.charWidth( 'x'); return new Dimension( w, h);}void process ( ActionEvent e ) { if ( (aListener != null) || ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0) ){ processEvent( e); }}void process ( ItemEvent e ) { if ( (iListener != null) || ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0) ){ processEvent( e); } if ((flags & IS_OLD_EVENT) != 0) { postEvent (Event.getEvent( e)); }}protected void processActionEvent( ActionEvent e) { if ( aListener != null ){ aListener.actionPerformed( e); }}protected void processItemEvent( ItemEvent e) { if (iListener != null) { iListener.itemStateChanged( e); }}public synchronized void remove ( String item) { removeElement( ip.rows.indexOf( item));}public synchronized void remove ( int index) { removeElement( index);}public synchronized void removeActionListener ( ActionListener l) { aListener = AWTEventMulticaster.remove( aListener, l);}public synchronized void removeAll () { clear();}void removeElement ( int index) { try { deselectElement( index, false, true); ip.rows.removeElementAt( index); ip.updateScrolls(); ip.repaintRows( index, ip.getVisibleRows() ); } catch ( Exception e) {}}void removeHScroll () { // remove( hScroll); ip.hScroll = null;}public synchronized void removeItemListener ( ItemListener l) { iListener = AWTEventMulticaster.remove( iListener, l);}public synchronized void repaintRow ( int idx) { ip.repaintItem( idx);}public synchronized void replaceItem ( String newValue, int index) { try { Object o = ip.rows.elementAt( index); ip.rows.setElementAt( newValue, index); ip.updateHScroll(); ip.repaintRows( index, 1); } catch ( Exception e) { }}public void requestFocus () { ip.requestFocus();}public void reshape ( int x, int y, int w, int h ) { super.reshape( x, y, w, h); // there is no need for validation of compound IS_NATIVE_LIKES, they are no Containers // in JDK, so we automagically have to re-layout them ip.innerLayout(); flags |= IS_VALID;}public void select ( int index ) { // It's unclear whether a user selection should fire an event of // not - but some code appears rely on event *NOT* being sent. selectEvent( index, false);}void selectEvent ( int index, boolean fire ) { if ( (index < 0) || (index > ip.rows.size() - 1) ) return; if ( isIndexSelected( index) ) return; if ( multipleMode ) { sel = index; multiSel.set( index); nSel++; } else if ( sel >= 0 ) { int oldSel = sel; sel = index; ip.repaintRows( oldSel, 1); if (fire) { notifyItem( new Integer( oldSel), ItemEvent.DESELECTED); } } else sel = index; ip.makeVisible( index); ip.repaintRows( index, 1); if (fire) { notifyItem( new Integer( index), ItemEvent.SELECTED); }}public void setBackground ( Color c) { // Ideally, we would just do a super.setBackground(), but that would give us // a strange look for the scrollbar backgrounds. If we just forward here, we also // have to resolve getBackground() //super.setBackground( c); ip.setBackground( c);}public void setEnabled ( boolean isEnabled ) { super.setEnabled( isEnabled); ip.setEnabled( isEnabled);}public void setFont ( Font fnt) { super.setFont( fnt); ip.setFont( fnt); ip.updateScrolls();}public void setForeground ( Color c) { //super.setForeground( c); ip.setForeground( c);}public synchronized void setMultipleMode ( boolean b) { setMultipleSelections(b);}/** * @deprecated */public synchronized void setMultipleSelections ( boolean b ) { if ( multipleMode == b ) return; if ( multipleMode ){ multiSel = null; nSel = 0; multipleMode = false; } else { multiSel = new BitSet(); nSel = 0; multipleMode = true; }}public void update ( Graphics g ) { paint( g); // no background blanking required}void vPosChange ( int dy) {}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -