下面列出了怎么用java.awt.ItemSelectable的API类实例代码及写法,或者点击链接到github查看源代码。
/**
*
* @param tree
* @param value
* @param selected
* @param expanded
* @param leaf
* @param row
* @return
*/
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected,
boolean expanded, boolean leaf, int row) {
Component editor = renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf,
row, true);
ItemListener itemListener = (ItemEvent itemEvent) -> {
if (stopCellEditing()) {
fireEditingStopped();
}
};
if (editor instanceof JCheckBox) {
((ItemSelectable) editor).addItemListener(itemListener);
}
return editor;
}
@Override
public void itemStateChanged(ItemEvent e) {
ItemSelectable is = e.getItemSelectable();
if (is == matchCase) {
matchCaseChanged();
} else if (is == textToFindType) {
regexpChanged();
}
}
/**
* Method declaration
*
*
* @param e
*/
public void itemStateChanged(ItemEvent e) {
ItemSelectable item = e.getItemSelectable();
if (item == lTable) {
if (iSelectionStep == SELECT_SOURCE_TABLES) {
String table = lTable.getSelectedItem();
int selected = ((Integer) e.getItem()).intValue();
for (int i = 0; i < tTable.size(); i++) {
TransferTable t = (TransferTable) tTable.elementAt(i);
if (t == null) {
continue;
}
if (i == selected) {
saveTable();
displayTable(t);
updateEnabled(true);
}
}
}
} else {
// it must be a checkbox
saveTable();
updateEnabled(true);
}
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an {@code ItemEvent} object.
* <p> This method throws an
* {@code IllegalArgumentException} if {@code source}
* is {@code null}.
*
* @param source The {@code ItemSelectable} object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if {@code source} is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an {@code ItemEvent} object.
* <p> This method throws an
* {@code IllegalArgumentException} if {@code source}
* is {@code null}.
*
* @param source The {@code ItemSelectable} object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if {@code source} is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}
/**
* Returns the originator of the event.
*
* @return the ItemSelectable object that originated the event.
*/
public ItemSelectable getItemSelectable() {
return (ItemSelectable)source;
}
/**
* Constructs an <code>ItemEvent</code> object.
* <p> This method throws an
* <code>IllegalArgumentException</code> if <code>source</code>
* is <code>null</code>.
*
* @param source The <code>ItemSelectable</code> object
* that originated the event
* @param id The integer that identifies the event type.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @param item An object -- the item affected by the event
* @param stateChange An integer that indicates whether the item was
* selected or deselected.
* For information on allowable values, see
* the class description for {@link ItemEvent}
* @throws IllegalArgumentException if <code>source</code> is null
* @see #getItemSelectable()
* @see #getID()
* @see #getStateChange()
*/
public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) {
super(source, id);
this.item = item;
this.stateChange = stateChange;
}