本文整理汇总了Java中java.util.EventObject.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java EventObject.getSource方法的具体用法?Java EventObject.getSource怎么用?Java EventObject.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.EventObject
的用法示例。
在下文中一共展示了EventObject.getSource方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: confirm
import java.util.EventObject; //导入方法依赖的package包/类
public void confirm(EventObject fe) {
JTextField tf = (JTextField) fe.getSource();
JComboBox combo = (JComboBox) tf.getParent();
if (combo==null)
return;
if (fe instanceof FocusEvent) {
combo.getEditor().getEditorComponent().removeFocusListener(this);
} else {
combo.getEditor().getEditorComponent().removeKeyListener(this);
}
Configuration config = configName==null ?
ConfigurationsManager.getDefault().duplicate(lastSelected, tf.getText(), tf.getText()):
ConfigurationsManager.getDefault().create(tf.getText(), tf.getText());
combo.setSelectedItem(config);
combo.setEditable(false);
currentActiveItem = null;
}
示例2: isCellEditable
import java.util.EventObject; //导入方法依赖的package包/类
@Override
public boolean isCellEditable(EventObject anEvent) {
if (anEvent.getSource() instanceof JTable) {
JTable table = (JTable) anEvent.getSource();
if (anEvent instanceof MouseEvent) {
MouseEvent event = (MouseEvent) anEvent;
Point p = event.getPoint();
int row = table.rowAtPoint(p);
int col = table.columnAtPoint(p);
Rectangle rect = table.getCellRect(row, col, true);
p.translate(-rect.x, -rect.y);
System.out.println("isCellEditable("+anEvent+")");
System.out.println("Point "+p+"in rectangle "+rect);
if (p.x > rect.width - 24) {
// last 24 points not editable
return false;
}
}
}
return true;
}
示例3: isCellEditable
import java.util.EventObject; //导入方法依赖的package包/类
/**
* If the <code>realEditor</code> returns true to this
* message, <code>prepareForEditing</code>
* is messaged and true is returned.
*/
public boolean isCellEditable(EventObject event) {
boolean retValue = false;
boolean editable = false;
if (event != null) {
if (event.getSource() instanceof JTree) {
setTree((JTree)event.getSource());
if (event instanceof MouseEvent) {
TreePath path = tree.getPathForLocation(
((MouseEvent)event).getX(),
((MouseEvent)event).getY());
editable = (lastPath != null && path != null &&
lastPath.equals(path));
if (path!=null) {
lastRow = tree.getRowForPath(path);
Object value = path.getLastPathComponent();
boolean isSelected = tree.isRowSelected(lastRow);
boolean expanded = tree.isExpanded(path);
TreeModel treeModel = tree.getModel();
boolean leaf = treeModel.isLeaf(value);
determineOffset(tree, value, isSelected,
expanded, leaf, lastRow);
}
}
}
}
if(!realEditor.isCellEditable(event))
return false;
if(canEditImmediately(event))
retValue = true;
else if(editable && shouldStartEditingTimer(event)) {
startEditingTimer();
}
else if(timer != null && timer.isRunning())
timer.stop();
if(retValue)
prepareForEditing();
return retValue;
}
示例4: checkEventSource
import java.util.EventObject; //导入方法依赖的package包/类
protected boolean checkEventSource(EventObject event) {
boolean isSourceFromConnector = false;
Object source = event.getSource();
if (event instanceof ConnectorEvent) {
if (source instanceof DatabaseObject) {
Connector connector = ((DatabaseObject)source).getConnector();
if ((connector != null) && (connector.equals(this.connector)))
isSourceFromConnector = true;
}
}
return isSourceFromConnector;
}
示例5: shouldSelectCell
import java.util.EventObject; //导入方法依赖的package包/类
@Override
public boolean shouldSelectCell(EventObject anEvent) {
if (!(anEvent.getSource() instanceof Outline)) {
return false;
}
Outline outline = (Outline) anEvent.getSource();
if (!(anEvent instanceof MouseEvent)) {
return false;
}
MouseEvent event = (MouseEvent) anEvent;
Point p = event.getPoint();
// Locate the editor under the event location
//int column = outline.columnAtPoint(p);
int row = outline.rowAtPoint(p);
Node n = DelegatingCellRenderer.getNodeAt(outline, row);
if (n instanceof TreeModelNode) {
TreeModelNode tmn = (TreeModelNode) n;
TableRendererModel trm = tmn.getModel();
try {
if (trm.canEditCell(tmn.getObject(), columnID)) {
TableCellEditor editor = trm.getCellEditor(tmn.getObject(), columnID);
if (editor != null) {
return editor.shouldSelectCell(anEvent);
}
}
} catch (UnknownTypeException ex) {
}
}
return defaultEditor.shouldSelectCell(anEvent);
}
示例6: confirm
import java.util.EventObject; //导入方法依赖的package包/类
private void confirm(EventObject fe) {
JTextField tf = (JTextField) fe.getSource();
JComboBox combo = (JComboBox) tf.getParent();
if (combo==null)
return;
if (fe instanceof FocusEvent) {
combo.getEditor().getEditorComponent().removeFocusListener(this);
} else {
combo.getEditor().getEditorComponent().removeKeyListener(this);
}
Configuration config = lastSelected;
config.setDisplayName(tf.getText());
combo.setSelectedItem(config);
combo.setEditable(false);
}
示例7: checkEventSource
import java.util.EventObject; //导入方法依赖的package包/类
protected boolean checkEventSource(EventObject event) {
boolean isSourceFromConnector = false;
Object source = event.getSource();
if (event instanceof ConnectorEvent) {
if (source instanceof DatabaseObject) {
Connector connector = ((DatabaseObject)source).getConnector();
if ((connector != null) && (connector.equals(this.connector)))
isSourceFromConnector = true;
}
}
return isSourceFromConnector;
}
示例8: checkEventSource
import java.util.EventObject; //导入方法依赖的package包/类
protected boolean checkEventSource(EventObject event) {
boolean isSourceFromSequence = false;
Object source = event.getSource();
if (event instanceof SequenceEvent) {
if ((source instanceof Sequence) || (source instanceof Step)) {
Sequence sequence = null;
if (source instanceof Sequence) sequence = (Sequence)source;
if (source instanceof Step) sequence = ((Step)source).getParentSequence();
if ((sequence != null) && (sequence.equals(this.sequence) || sequence.getOriginal().equals(this.sequence)))
isSourceFromSequence = true;
}
}
return isSourceFromSequence;
}
示例9: trySendEscToDialog
import java.util.EventObject; //导入方法依赖的package包/类
private void trySendEscToDialog(JTable jt) {
// System.err.println("SendEscToDialog");
EventObject ev = EventQueue.getCurrentEvent();
if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ESCAPE)) {
if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
return;
}
if (
ev.getSource() instanceof JTextComponent &&
((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
) {
return;
}
InputMap imp = jt.getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap am = jt.getRootPane().getActionMap();
KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
Object key = imp.get(escape);
if (key != null) {
Action a = am.get(key);
if (a != null) {
if (Boolean.getBoolean("netbeans.proppanel.logDialogActions")) { //NOI18N
System.err.println("Action bound to escape key is " + a); //NOI18N
}
//Actions registered with deprecated registerKeyboardAction will
//need this lookup of the action command
String commandKey = (String) a.getValue(Action.ACTION_COMMAND_KEY);
if (commandKey == null) {
commandKey = "cancel"; //NOI18N
}
a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
}
}
}
}
示例10: getSipListener
import java.util.EventObject; //导入方法依赖的package包/类
private SipListener getSipListener(EventObject sipEvent) {
SipProvider source = (SipProvider) sipEvent.getSource();
SipListener listener = (SipListener) providerTable.get(source);
assertTrue(listener != null);
return listener;
}