當前位置: 首頁>>代碼示例>>Java>>正文


Java EventObject.getSource方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ConfigurationsComboModel.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:TableRendererTest.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:45,代碼來源:DefaultTreeCellEditor.java

示例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;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:13,代碼來源:AbstractConnectorCompositeWrap.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:DelegatingCellEditor.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ConfigurationsComboModel.java

示例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;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:13,代碼來源:AbstractConnectorComposite.java

示例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;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:15,代碼來源:AbstractSequenceComposite.java

示例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
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:BaseTable.java

示例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;
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:7,代碼來源:TlsTest.java


注:本文中的java.util.EventObject.getSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。