⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccombo.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
** This operation will fail when the index is out* of range or an item could not be removed from* the OS.** @param index the index of the item** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_ITEM_NOT_REMOVED)*	when the operation fails*/public void remove (int index) {	checkWidget();	list.remove (index);}/*** Removes a range of items.* <p>* Indexing is zero based.  The range of items* is from the start index up to and including* the end index.** This operation will fail when the index is out* of range or an item could not be removed from* the OS.** @param start the start of the range* @param end the end of the range** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_ITEM_NOT_REMOVED)*	when the operation fails*/public void remove (int start, int end) {	checkWidget();	list.remove (start, end);}/*** Removes an item.* <p>* This operation will fail when the item* could not be removed from the OS.** @param string the search item** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when string is null* @exception SWTError(ERROR_ITEM_NOT_REMOVED)*	when the operation fails*/public void remove (String string) {	checkWidget();	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	list.remove (string);}/*** Removes all items.* <p>* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed*/public void removeAll () {	checkWidget();	text.setText (""); //$NON-NLS-1$	list.removeAll ();}/**	 * Removes the listener.* <p>** @param listener the listener** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when listener is null*/public void removeModifyListener (ModifyListener listener) {	checkWidget();	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	removeListener(SWT.Modify, listener);	}/**	 * Removes the listener.* <p>** @param listener the listener** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when listener is null*/public void removeSelectionListener (SelectionListener listener) {	checkWidget();	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	removeListener(SWT.Selection, listener);	removeListener(SWT.DefaultSelection,listener);	}/*** Selects an item.* <p>* If the item at an index is not selected, it is* selected. Indices that are out of* range are ignored.  Indexing is zero based.** @param index the index of the item** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed*/public void select (int index) {	checkWidget();	if (index == -1) {		list.deselectAll ();		text.setText (""); //$NON-NLS-1$		return;	}	if (0 <= index && index < list.getItemCount()) {		if (index != getSelectionIndex()) {			text.setText (list.getItem (index));			text.selectAll ();			list.select (index);			list.showSelection ();		}	}}public void setBackground (Color color) {	super.setBackground(color);	background = color;	if (text != null) text.setBackground(color);	if (list != null) list.setBackground(color);	if (arrow != null) arrow.setBackground(color);}/** * Sets the editable state. * * @param editable the new editable state * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 * */public void setEditable (boolean editable) {	checkWidget ();	text.setEditable(editable);}public void setEnabled (boolean enabled) {	super.setEnabled(enabled);	if (popup != null) popup.setVisible (false);	if (text != null) text.setEnabled(enabled);	if (arrow != null) arrow.setEnabled(enabled);}public boolean setFocus () {	checkWidget();	return text.setFocus ();}public void setFont (Font font) {	super.setFont (font);	this.font = font;	text.setFont (font);	list.setFont (font);	internalLayout ();}public void setForeground (Color color) {	super.setForeground(color);	foreground = color;	if (text != null) text.setForeground(color);	if (list != null) list.setForeground(color);	if (arrow != null) arrow.setForeground(color);}/*** Sets the text of an item; indexing is zero based.** This operation will fail when the index is out* of range or an item could not be changed in* the OS.** @param index the index for the item* @param string the item** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when items is null* @exception SWTError(ERROR_ITEM_NOT_MODIFIED)*	when the operation fails*/public void setItem (int index, String string) {	checkWidget();	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	list.setItem (index, string);}/*** Sets all items.** @param items the array of items** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when items is null* @exception SWTError(ERROR_ITEM_NOT_ADDED)*	when the operation fails*/public void setItems (String [] items) {	checkWidget();	if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	if (!text.getEditable()) text.setText (""); //$NON-NLS-1$	list.setItems (items);}/*** Sets the new selection.** @param selection point representing the start and the end of the new selection** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when selection is null*/public void setSelection (Point selection) {	checkWidget();	if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	text.setSelection (selection.x, selection.y);}/*** Sets the widget text.** @param string the widget text** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_NULL_ARGUMENT)*	when string is null*/public void setText (String string) {	checkWidget();	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	int index = list.indexOf (string);	if (index == -1) {		list.deselectAll ();		text.setText (string);		return;	}	text.setText (string);	text.selectAll ();	list.setSelection (index);	list.showSelection ();}/*** Sets the text limit.* * @param limit new text limit** @exception SWTError(ERROR_THREAD_INVALID_ACCESS)*	when called from the wrong thread* @exception SWTError(ERROR_WIDGET_DISPOSED)*	when the widget has been disposed* @exception SWTError(ERROR_CANNOT_BE_ZERO)*	when limit is 0*/public void setTextLimit (int limit) {	checkWidget();	text.setTextLimit (limit);}public void setToolTipText (String string) {	checkWidget();	super.setToolTipText(string);	arrow.setToolTipText (string);	text.setToolTipText (string);		}public void setVisible (boolean visible) {	super.setVisible(visible);	if (!visible) popup.setVisible(false);}/** * Sets the number of items that are visible in the drop * down portion of the receiver's list. * * @param count the new number of items to be visible * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> *  * @since 3.0 */public void setVisibleItemCount (int count) {	checkWidget ();	if (count < 0) return;	visibleItemCount = count;}String stripMnemonic (String string) {	int index = 0;	int length = string.length ();	do {		while ((index < length) && (string.charAt (index) != '&')) index++;		if (++index >= length) return string;		if (string.charAt (index) != '&') {			return string.substring(0, index-1) + string.substring(index, length);		}		index++;	} while (index < length); 	return string;}void textEvent (Event event) {	switch (event.type) {		case SWT.FocusIn: {			handleFocus (SWT.FocusIn);			break;		}		case SWT.KeyDown: {			if (event.character == SWT.CR) {				dropDown (false);				Event e = new Event();				e.time = event.time;				e.stateMask = event.stateMask;				notifyListeners(SWT.DefaultSelection, e);			}			//At this point the widget may have been disposed.			// If so, do not continue.			if (isDisposed()) break;						if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {				if ((event.stateMask & SWT.ALT) != 0) {					boolean dropped = isDropped ();					text.selectAll ();					if (!dropped) setFocus ();					dropDown (!dropped);					break;				}				int oldIndex = getSelectionIndex ();				if (event.keyCode == SWT.ARROW_UP) {					select (Math.max (oldIndex - 1, 0));				} else {					select (Math.min (oldIndex + 1, getItemCount () - 1));				}						if (oldIndex != getSelectionIndex ()) {					Event e = new Event();					e.time = event.time;					e.stateMask = event.stateMask;					notifyListeners(SWT.Selection, e);				}				//At this point the widget may have been disposed.				// If so, do not continue.				if (isDisposed()) break;			}						// Further work : Need to add support for incremental search in 			// pop up list as characters typed in text widget									Event e = new Event();			e.time = event.time;			e.character = event.character;			e.keyCode = event.keyCode;			e.stateMask = event.stateMask;			notifyListeners(SWT.KeyDown, e);			break;		}		case SWT.KeyUp: {			Event e = new Event();			e.time = event.time;			e.character = event.character;			e.keyCode = event.keyCode;			e.stateMask = event.stateMask;			notifyListeners(SWT.KeyUp, e);			break;		}		case SWT.Modify: {			list.deselectAll ();			Event e = new Event();			e.time = event.time;			notifyListeners(SWT.Modify, e);			break;		}		case SWT.MouseDown: {			if (event.button != 1) return;			if (text.getEditable ()) return;			boolean dropped = isDropped ();			text.selectAll ();			if (!dropped) setFocus ();			dropDown (!dropped);			break;		}		case SWT.MouseUp: {			if (event.button != 1) return;			if (text.getEditable ()) return;			text.selectAll ();			break;		}		case SWT.Traverse: {					switch (event.detail) {				case SWT.TRAVERSE_RETURN:				case SWT.TRAVERSE_ARROW_PREVIOUS:				case SWT.TRAVERSE_ARROW_NEXT:					// The enter causes default selection and					// the arrow keys are used to manipulate the list contents so					// do not use them for traversal.					event.doit = false;					break;			}						Event e = new Event();			e.time = event.time;			e.detail = event.detail;			e.doit = event.doit;			e.character = event.character;			e.keyCode = event.keyCode;			notifyListeners(SWT.Traverse, e);			event.doit = e.doit;			event.detail = e.detail;			break;		}	}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -