📄 numberspinner.java
字号:
package org.uispec4j;
import junit.framework.Assert;
import org.uispec4j.assertion.Assertion;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
/**
* Wrapper for JSpinner components implementing a SpinnerNumberModel.
*/
public class NumberSpinner extends Spinner {
private SpinnerNumberModel model;
public NumberSpinner(JSpinner jSpinner) {
super(jSpinner);
SpinnerModel model = jSpinner.getModel();
if (!model.getClass().isAssignableFrom(SpinnerNumberModel.class)) {
throw new ItemNotFoundException("Expected JSpinner using a SpinnerNumberModel");
}
this.model = (SpinnerNumberModel) model;
}
/**
* Checks that the list spinner displays starts with the given value
*/
public Assertion minEquals(final int expectedMin) {
return new Assertion() {
public void check() throws Exception {
Assert.assertEquals(new Integer(expectedMin), model.getMinimum());
}
};
}
/**
* Checks that the list spinner displays starts with the given value
*/
public Assertion maxEquals(final int expectedMax) {
return new Assertion() {
public void check() throws Exception {
Assert.assertEquals(new Integer(expectedMax), model.getMaximum());
}
};
}
/**
* Checks that the list spinner computes previous and next value with the given value.
*/
public Assertion stepSizeEquals(final int expectedStepSize) {
return new Assertion() {
public void check() throws Exception {
Assert.assertEquals(new Integer(expectedStepSize), model.getStepSize());
}
};
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -