本文整理匯總了Java中javax.swing.AbstractButton.setActionCommand方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractButton.setActionCommand方法的具體用法?Java AbstractButton.setActionCommand怎麽用?Java AbstractButton.setActionCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.setActionCommand方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSetValue
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Test
public void testSetValue() {
final AbstractButton buttonA = new JButton();
buttonA.setActionCommand("TRUaN");
final AbstractButton buttonB = new JButton();
buttonB.setActionCommand("[email protected]_");
final AbstractButton buttonC = new JButton();
buttonC.setActionCommand("#Oq%n");
group.add(buttonA);
group.add(buttonB);
group.add(buttonC);
ButtonGroupHelper.setValue(group, "[email protected]_");
assertThat(buttonB.isSelected()).isTrue();
}
示例2: testSetValueObject
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Test
public void testSetValueObject() {
final AbstractButton buttonA = new JButton();
buttonA.setActionCommand("iqGfVwJDLd");
final AbstractButton buttonB = new JButton();
buttonB.setActionCommand("ouzioKGsKi");
final AbstractButton buttonC = new JButton();
buttonC.setActionCommand("pKVEAoQzmr");
group.add(buttonA);
group.add(buttonB);
group.add(buttonC);
ButtonGroupHelper.setValue(group, new Object() {
@Override
public String toString() {
return "ouzioKGsKi";
}
});
assertThat(buttonB.isSelected()).isTrue();
}
示例3: testGetValue
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Test
public void testGetValue() {
final AbstractButton buttonA = new JButton();
buttonA.setActionCommand("29zo4");
final AbstractButton buttonB = new JButton();
buttonB.setSelected(true);
buttonB.setActionCommand("Y6ddy");
group.add(buttonA);
group.add(buttonB);
assertThat(ButtonGroupHelper.getValue(group)).isEqualTo("Y6ddy");
}
示例4: testSetValueNotFound
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Test
public void testSetValueNotFound() {
final AbstractButton buttonA = new JButton();
buttonA.setActionCommand("*VgyA");
final AbstractButton buttonB = new JButton();
buttonB.setActionCommand("s8vOP");
group.add(buttonA);
group.add(buttonB);
assertThatThrownBy(() -> ButtonGroupHelper.setValue(group, "OD>5&"))
.isInstanceOf(NoSuchElementException.class)
.hasMessage("Could not find a button with action command `OD>5&`.");
}