本文整理汇总了Java中javax.swing.JButton.getClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.getClientProperty方法的具体用法?Java JButton.getClientProperty怎么用?Java JButton.getClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.getClientProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
JButton btn = (JButton) event.getSource();
String pressedKey = (String) btn.getClientProperty("key");
if (CAPS.equals(pressedKey)) {
for (JButton button : buttons) {
String text = button.getText();
text = caps ? text.toLowerCase() : text.toUpperCase();
button.setText(text);
}
caps = !caps;
return;
}
if (BACKSPACE.equals(pressedKey)) {
if (password.length() > 0) {
password = password.substring(0, password.length() - 1);
}
} else if (CLEAR.equals(pressedKey)) {
password = "";
} else {
password += btn.getText();
}
passwordField.setText(password);
}
示例2: actionPerformed
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Action listener method for buttons and node set chooser
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton) {
JButton source = (JButton)e.getSource();
DTNHost host = (DTNHost)source.getClientProperty(HOST_KEY);
gui.setFocus(host);
}
else if (e.getSource() == groupChooser) {
setNodes(groupChooser.getSelectedIndex() * MAX_NODE_COUNT);
}
}
示例3: actionPerformed
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Action listener for log entry (host & message) buttons
*/
public void actionPerformed(ActionEvent e) {
JButton source = (JButton)e.getSource();
if (source.getClientProperty(HOST_PROP) != null) {
// button was a host button -> focus it on GUI
gui.setFocus((DTNHost)source.getClientProperty(HOST_PROP));
}
else if (source.getClientProperty(MSG_PROP) != null) {
// was a message button -> show information about the message
Message m = (Message)source.getClientProperty(MSG_PROP);
gui.getInfoPanel().showInfo(m);
}
}