下面列出了javax.swing.event.ChangeEvent#getSource() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void stateChanged(ChangeEvent e) {
final ServerRegistry registry = (ServerRegistry) e.getSource();
List<ServerInstance> current = new ArrayList<ServerInstance>();
for (ServerInstanceProvider provider : registry.getProviders()) {
current.addAll(provider.getInstances());
}
List<ServerInstance> expected = steps.get(stepIndex++);
assertEquals(expected.size(), current.size());
for (ServerInstance instance : expected) {
current.remove(instance);
}
assertTrue(current.isEmpty());
}
public void stateChanged(ChangeEvent e) {
// Listen to jnt file name change
Object obj = e.getSource();
if (obj instanceof FileTextFieldAndChooser){
if (obj.equals(jntfileTextFieldAndChooser)){
// If a non empty string is available in the jOpenSimFilenameTextField try to use it, otherwsie makeup one.
String jntFilename= getJointFilename();
if (jntFilename==null || !jntfileTextFieldAndChooser.getFileIsValid()) return;
// Here we have a real jnt file, make up a name for the .osim file if none specified
File f = new File(jntFilename);
String candidateName = getUniqueOsimFilenameForJntFile(f);
// Here we know we have a valid name, show the name as default
jOpenSimFilenameTextField.setText(candidateName);
}
}
}
@Override
public void stateChanged(final ChangeEvent event) {
Map.Entry<URL,JavaFileFilterImplementation>[] entries;
synchronized (this.listensOn) {
entries = listensOn.entrySet().toArray(new Map.Entry[listensOn.size()]);
}
final Object source = event.getSource();
for (Map.Entry<URL,JavaFileFilterImplementation> entry : entries) {
if (entry.getValue().equals(source)) {
final URL root = entry.getKey();
try {
verify(root);
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
} catch (URISyntaxException use) {
Exceptions.printStackTrace(use);
} finally {
IndexingManager.getDefault().refreshIndex(root, null, true);
}
}
}
}
public void stateChanged(final ChangeEvent e) {
final Runnable action = new Runnable() {
public void run() {
NodeList list = (NodeList) e.getSource();
List objects = list.keys();
synchronized (keys) {
removeKeys(list);
addKeys(list, objects);
}
final Collection<NodeListKeyWrapper> ks = createKeys();
NodeFactorySupport.createWaitNode();
EventQueue.invokeLater(new RunnableImpl(DelegateChildren.this, ks));
}
};
if (ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess()) {
//having lock (non blocking)
action.run();
}
else {
//may block for > 10s when waiting on project save
RP.post(action);
}
}
@Override
public void stateChanged(ChangeEvent e) {
final Object source = e.getSource();
if (source instanceof Member) {
/*
* HP changes can come from the game loop. Resizes also result
* in ratio changes, and they come from EDT, but we can ignore
* those as they result in redraws anyway.
*/
if (!SwingUtilities.isEventDispatchThread()) {
memberChanged((Member) source);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
memberChanged((Member) source);
}
});
}
}
}
public void stateChanged(ChangeEvent e) {
AbstractButton abstractButton = (AbstractButton) e.getSource();
boolean isZircon = abstractButton.getModel().isSelected();
fractionPbBlankMassText.get(row).setEnabled(!isZircon);
// added aug 2010
if (isZircon) {
// fires itemlistener
fractionInitialPbChoice.get(row).setSelectedIndex(0);
}
fractionInitialPbChoice.get(row).setEnabled(!isZircon);
updateInitialPbModelChooserForRow(fraction, isZircon, row);
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == tabbedPane && tabbedPane.getSelectedComponent() == basePanel) {
if(diffProvider != null) {
commitTable.setModifiedFiles(diffProvider.getModifiedFiles());
}
} else if(e.getSource() == parameters || e.getSource() == commitTable) {
valuesChanged();
}
}
public void stateChanged(ChangeEvent e) {
if (e.getSource() == tokenList) {
reschedule();
} else {
doUpdateCurrentVisibleSpan();
}
}
/**
* Slider change
*/
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider) e.getSource();
if (source != jXSlider) return;
double theValue = jXSlider.getValue()*step+min;
setTheValue(theValue, true, false, true, (source.getValueIsAdjusting()));
}
@Override
public void stateChanged(ChangeEvent e) {
if (enabled) {
TextDetail td = (TextDetail) e.getSource();
int origMatchesSelected = selectedMatchesCount;
selectedMatchesCount += td.isSelected() ? 1 : -1;
changeSupport.firePropertyChange(PROP_MATCHES_SELECTED,
origMatchesSelected, selectedMatchesCount);
if (selected && selectedMatchesCount == 0) {
setSelected(false);
} else if (!selected && selectedMatchesCount > 0) {
setSelected(true);
}
}
}
@Override
public void stateChanged (ChangeEvent e)
{
JSpinner s = (JSpinner) e.getSource();
if (s == fontName.getSpinner()) {
// New font name
defineFont();
} else {
if (s == fontBase) {
// New font base
changeCode();
} else if (s == fontSize.getSpinner()) {
// New font size
defineFont();
} else if (s == pointCode.getSpinner()) {
// New point code
changeCode();
} else if (s == hexaCode.getSpinner()) {
// New hexa point code
changeHexaCode();
} else if ((s == xOffset.getSpinner())
|| (s == yOffset.getSpinner())) {
// New drawing offset
} else if ((s == width.getSpinner())
|| (s == height.getSpinner())) {
// New drawing dimension
resizeDrawing();
}
}
// For all
image = buildImage();
frame.repaint();
}
public void stateChanged(ChangeEvent ev)
{
if (ev.getSource() instanceof Layout)
{
repaint();
}
}
public void stateChanged(ChangeEvent chev) {
Object source = chev.getSource();
if (source instanceof Breakpoint.VALIDITY) {
setValidity((Breakpoint.VALIDITY) source, chev.toString());
} else {
throw new UnsupportedOperationException(chev.toString());
}
}
public void stateChanged(ChangeEvent e) {
SingleSelectionModel model = (SingleSelectionModel) e.getSource();
boolean srcSelected = model.getSelectedIndex() == 1;
if(currentTabDemo != currentDemo && demoSrcPane != null && srcSelected) {
demoSrcPane.setText(getString("SourceCode.loading"));
repaint();
}
if(currentTabDemo != currentDemo && srcSelected) {
currentTabDemo = currentDemo;
setSourceCode(currentDemo);
}
}
public void stateChanged(ChangeEvent e) {
JTabbedPane tabPane = (JTabbedPane)e.getSource();
tabPane.revalidate();
tabPane.repaint();
}
@Override
public void editingStopped(ChangeEvent evt) {
CellEditor editor = (CellEditor)evt.getSource();
Input<?> in = (Input<?>)editor.getCellEditorValue();
Entity ent = editor.getTable().getEntity();
final String newValue = editor.getValue();
// The value has not changed
if (in.getValueString().equals(newValue) && in.isValid()) {
editor.propTable.setPresentCellEditor(null);
return;
}
// Adjust the user's entry to standardise the syntax
String str = newValue.trim();
if (!str.isEmpty())
str = in.applyConditioning(str);
try {
// Parse the keyword inputs
KeywordIndex kw = InputAgent.formatInput(in.getKeyword(), str);
InputAgent.storeAndExecute(new KeywordCommand(ent, kw));
in.setValid(true);
}
catch (InputErrorException exep) {
boolean entityChanged = (EditBox.getInstance().getCurrentEntity() != ent);
// Reset the Input Editor to the original tab
final EditTable table = editor.getTable();
if (!entityChanged) {
EditBox.getInstance().setTab(table.getTab());
}
if (editor.canRetry() && !entityChanged) {
boolean editSelected = GUIFrame.showErrorEditDialog("Input Error",
exep.source,
exep.position,
"Input error:",
exep.getMessage(),
"Do you want to continue editing, or reset the input?");
if (editSelected) {
// Any editor that supports retry should implement the following
final int row = editor.getRow();
final int col = editor.getCol();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
table.setRetry(newValue, row, col);
table.editCellAt(row, col);
}
});
} else {
GUIFrame.updateUI();
}
return;
}
GUIFrame.showErrorDialog("Input Error",
exep.source,
exep.position,
"Input error:",
exep.getMessage(),
"Value will be cleared.");
GUIFrame.updateUI();
return;
}
finally {
editor.propTable.setPresentCellEditor(null);
}
}
@Override
public void stateChanged(ChangeEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
lowerCaseFileNameCheckBox.setEnabled(source.isVisible() && source.isSelected());
RenamePanel.this.parent.stateChanged(null);
}
@Override
public void stateChanged(ChangeEvent e) {
JTabbedPane p = (JTabbedPane)e.getSource();
setSessionTitle((SessionPanel)p.getSelectedComponent());
}
public void stateChanged(ChangeEvent e) {
JSlider barra = (JSlider) (e.getSource());
JTextField lbl = (JTextField)(attributesPanel.getComponent("txtValue").getComponent());
lbl.setText(""+barra.getValue());
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == tabbedPane && tabbedPane.getSelectedComponent() == basePanel) {
commitTable.setModifiedFiles(new HashSet<File>(getModifiedFiles().keySet()));
}
}