本文整理汇总了Java中javax.swing.event.ChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java ChangeListener类的具体用法?Java ChangeListener怎么用?Java ChangeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChangeListener类属于javax.swing.event包,在下文中一共展示了ChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupUI
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private void setupUI() {
setLayout(new BorderLayout());
tabbedPane = new JTabbedPane();
add(tabbedPane, BorderLayout.CENTER);
addTabs();
restoreLastTab();
//add a listener so we can store the current tab when it changes.
tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int selection = tabbedPane.getSelectedIndex();
if (selection >= 0 && selection < gradleTabs.size()) {
SettingsNode rootNode = settings.addChildIfNotPresent(MAIN_PANEL);
rootNode.setValueOfChild(CURRENT_TAB, gradleTabs.get(selection).getName());
}
}
});
}
示例2: PartSpinner
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private PartSpinner(int dimension) {
super(new PartSpinnerModel());
this.dimension = dimension;
setupFilter();
addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
Part part = controller.getSelectedPart();
PartSpinner spinner = (PartSpinner) e.getSource();
if(part != null && ((JSpinner.DefaultEditor)getEditor()).getTextField().hasFocus()) {
double d = (double) spinner.getValue();
float[] prevValues = part.getValues();
part.setValue((float) d, dimension);
controller.mainController.versionController.applyChange(new ChangeSetValues(prevValues, part.getValues(), part.getName(), (int) controller.getTime()));
}
}
});
}
示例3: setTypeFields
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private ChangeListener setTypeFields() {
ChangeListener changeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int count = (int) roomTypeSpinner.getValue();
if (count > typeValue) {
for (int i = 0; i < count; i++) {
roomTypeFields[i].setVisible(true);
roomTypeFields[i].revalidate();
roomTypeFields[i].repaint();
}
} else if (count < typeValue) {
roomTypeFields[count].setVisible(false);
roomTypeFields[count].revalidate();
roomTypeFields[count].repaint();
}
typeValue = count;
}
};
return changeListener;
}
示例4: tabbedPaneFactory
import javax.swing.event.ChangeListener; //导入依赖的package包/类
/**
* Creates new {@link JTabbedPane} with {@link ChangeListener}.
*/
private void tabbedPaneFactory() {
tabs = new JTabbedPane();
tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
tabs.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int index = tabs.getSelectedIndex();
activeEditor = editors.get(index);
if (editors.size() > 1) {
activeEditor.updateStatusBar();
}
updateFrameTitle();
}
});
}
示例5: updateSpinner
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private void updateSpinner() {
jNumField.setValue(threshold);
jNumField.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Integer i = (Integer) jNumField.getValue();
if (i.intValue() < 1) {
i = new Integer(1);
jNumField.setValue(i);
}
SemaphoreStrategy ss = (SemaphoreStrategy) stations.getSemaphoreStrategy(stationKey, classKey);
ss.setThreshold(i);
}
});
}
示例6: testFireForFiles
import javax.swing.event.ChangeListener; //导入依赖的package包/类
public void testFireForFiles() throws IOException {
final List<String> received = new ArrayList<String>();
ChangeListener list;
VisibilityQuery.getDefault().addChangeListener(list = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent ce) {
Assert.assertTrue(ce instanceof VisibilityQueryChangeEvent);
FileObject[] fos = ((VisibilityQueryChangeEvent)ce).getFileObjects();
Assert.assertEquals(2, fos.length);
received.add(fos[0].getName());
received.add(fos[1].getName());
}
});
try {
File f1 = createVersionedFile("f1", true);
File f2 = createVersionedFile("f2", true);
TestVCS.getInstance().getVisibilityQuery().fireVisibilityChanged(
new VCSFileProxy[] {
VCSFileProxy.createFileProxy(f1),
VCSFileProxy.createFileProxy(f2)});
assertTrue(received.contains(f1.getName()));
assertTrue(received.contains(f2.getName()));
} finally {
VisibilityQuery.getDefault().removeChangeListener(list);
}
}
示例7: fireChangeEvent
import javax.swing.event.ChangeListener; //导入依赖的package包/类
public synchronized void fireChangeEvent() {
ChangeEvent e = new ChangeEvent(this);
for (ChangeListener l : listeners) {
l.stateChanged(e);
}
}
示例8: mkCheckBox
import javax.swing.event.ChangeListener; //导入依赖的package包/类
protected JCheckBox mkCheckBox(final BooleanPref pref) {
final JCheckBox cb = make(new JCheckBox(pref.getTitleAction()));
pref2comp.put(pref, cb);
ChangeListener ctrl = new ChangeListener() {
public void stateChanged(ChangeEvent e) {
cb.setSelected(pref.get());
}
};
pref.addChangeListener(ctrl);
ctrl.stateChanged(null);
return cb;
}
示例9: getPanel
import javax.swing.event.ChangeListener; //导入依赖的package包/类
@Override
public CustomRefactoringPanel getPanel(ChangeListener parent) {
if (panel == null) {
panel = new MoveMembersPanel(selectedElements, parent);
}
return panel;
}
示例10: fireChangeEvent
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private void fireChangeEvent() {
Iterator<ChangeListener> it;
synchronized (listeners) {
it = new HashSet<>(listeners).iterator();
}
ChangeEvent ev = new ChangeEvent(this);
while (it.hasNext()) {
it.next().stateChanged(ev);
}
}
示例11: customerCounterListener
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private ChangeListener customerCounterListener() {
final ChangeListener spinnerListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
switch ((int) spinner.getValue()) {
case 1:
contentPanel.removeAll();
contentPanel.add(upperPanel, BorderLayout.NORTH);
contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST);
contentPanel.revalidate();
contentPanel.repaint();
break;
case 2:
contentPanel.removeAll();
contentPanel.add(upperPanel, BorderLayout.NORTH);
contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST);
contentPanel.add(customerFormTwo.setCustomerDetailPanel(), BorderLayout.EAST);
contentPanel.revalidate();
contentPanel.repaint();
break;
case 3:
contentPanel.removeAll();
contentPanel.add(upperPanel, BorderLayout.NORTH);
contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST);
contentPanel.add(customerFormTwo.setCustomerDetailPanel(), BorderLayout.EAST);
contentPanel.add(customerFormThree.setCustomerDetailPanel(), BorderLayout.CENTER);
contentPanel.revalidate();
contentPanel.repaint();
break;
default:
break;
}
}
};
return spinnerListener;
}
示例12: initFilterPanel
import javax.swing.event.ChangeListener; //导入依赖的package包/类
private void initFilterPanel() {
filterComponent = FilterComponent.create(true, true);
filterComponent.setHint(CLASS_NAME_FILTER);
filterComponent.setFilter(filterString, filterType);
filterComponent.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
String selectedRowContents = null;
int selectedRow = resTable.getSelectedRow();
if (selectedRow != -1) {
selectedRowContents = (String) resTable.getValueAt(selectedRow, 0);
}
filterString = filterComponent.getFilterValue();
filterType = filterComponent.getFilterType();
createFilteredIndexes();
resTable.invalidate();
jScrollPane.revalidate();
resTable.repaint();
if (selectedRowContents != null) {
resTable.selectRowByContents(selectedRowContents, 0, true);
}
}
});
add(filterComponent.getComponent(), BorderLayout.SOUTH);
}
示例13: AttachPanel
import javax.swing.event.ChangeListener; //导入依赖的package包/类
public AttachPanel(ChangeListener issueListener, FileObject referenceFile) {
initComponents();
qs = IssueQuickSearch.create(referenceFile);
qs.setEnabled(false);
qs.setChangeListener(issueListener);
qs.setChangeListener(this);
issuePanel.add(qs.getComponent(), BorderLayout.NORTH);
enableFields(false);
}
示例14: getScheduleAction
import javax.swing.event.ChangeListener; //导入依赖的package包/类
/**
* Create action for changing scheduling info for supplied nodes.
*
* <p>
* If one of the nodes does not support schedule handling, the action is disabled!</p>
*
* @param nodes
* @return
*/
private static Action getScheduleAction(final TaskNode... taskNodes) {
// Check the selected nodes - if one of the selected nodes does not
// support scheduling - don't offer it in the menu
boolean hasSchedule = true;
for (TaskNode tn : taskNodes) {
if (!tn.getTask().hasSchedule()) {
hasSchedule = false;
break;
}
}
IssueScheduleInfo schedule = null;
if (taskNodes.length == 1) {
schedule = taskNodes[0].getTask().getSchedule();
}
final DashboardUtils.SchedulingMenu scheduleMenu = DashboardUtils.createScheduleMenu(schedule);
//TODO weak listener??
final ChangeListener listener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
for (TaskNode taskNode : taskNodes) {
if (taskNode.getTask().hasSchedule()) {
taskNode.getTask().setSchedule(scheduleMenu.getScheduleInfo());
}
}
scheduleMenu.removeChangeListener(this);
}
};
scheduleMenu.addChangeListener(listener);
Action menuAction = scheduleMenu.getMenuAction();
menuAction.setEnabled(hasSchedule);
return menuAction;
}
示例15: removeChangeListener
import javax.swing.event.ChangeListener; //导入依赖的package包/类
public void removeChangeListener (ChangeListener l) {
changeListener = null;
}