本文整理汇总了Java中javax.swing.JButton.putClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.putClientProperty方法的具体用法?Java JButton.putClientProperty怎么用?Java JButton.putClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.putClientProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getToolbarPresenter
import javax.swing.JButton; //导入方法依赖的package包/类
public static Component getToolbarPresenter(Action action) {
JButton button = new JButton(action);
button.setBorderPainted(false);
button.setOpaque(false);
button.setText(null);
button.putClientProperty("hideActionText", Boolean.TRUE); // NOI18N
Object icon = action.getValue(Action.SMALL_ICON);
if (icon == null) {
icon = ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/terminal/action/local_term.png", false);// NOI18N
}
if (!(icon instanceof Icon)) {
throw new IllegalStateException("No icon provided for " + action); // NOI18N
}
button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) icon));
return button;
}
示例2: testIconsSystemAction24
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Test whether pressed, rollover and disabled 24x24 icons
* work for SystemAction.
*/
public void testIconsSystemAction24() throws Exception {
Action saInstance = SystemAction.get(TestSystemAction.class);
JButton jb = new JButton();
jb.putClientProperty("PreferredIconSize",new Integer(24));
Actions.connect(jb, saInstance);
Icon icon = jb.getIcon();
assertNotNull(icon);
checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon");
Icon rolloverIcon = jb.getRolloverIcon();
assertNotNull(rolloverIcon);
checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon");
Icon pressedIcon = jb.getPressedIcon();
assertNotNull(pressedIcon);
checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon");
Icon disabledIcon = jb.getDisabledIcon();
assertNotNull(disabledIcon);
checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon");
}
示例3: adjustButton
import javax.swing.JButton; //导入方法依赖的package包/类
private JButton adjustButton(JButton b) {
b.setBorderPainted(false);
b.setOpaque(false);
b.setText(null);
b.putClientProperty("hideActionText", Boolean.TRUE); // NOI18N
// NOI18N
return b;
}
示例4: getToolbarPresenter
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getToolbarPresenter() {
if (popup != null) {
JButton button = DropDownButtonFactory.createDropDownButton(
(ImageIcon) getValue(SMALL_ICON),
popup
);
button.putClientProperty("hideActionText", Boolean.TRUE); //NOI18N
button.setAction(this);
return button;
} else {
return new JButton(this);
}
}
示例5: testIconsAction24
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Test whether pressed, rollover and disabled 24x24 icons
* work for javax.swing.Action.
*/
public void testIconsAction24() throws Exception {
JButton jb = new JButton();
jb.putClientProperty("PreferredIconSize",new Integer(24));
Actions.connect(jb, new TestAction());
Icon icon = jb.getIcon();
assertNotNull(icon);
checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon24");
Icon rolloverIcon = jb.getRolloverIcon();
assertNotNull(rolloverIcon);
checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon24");
Icon pressedIcon = jb.getPressedIcon();
assertNotNull(pressedIcon);
checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon24");
Icon disabledIcon = jb.getDisabledIcon();
assertNotNull(disabledIcon);
checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon24");
Icon selectedIcon = jb.getSelectedIcon();
assertNotNull(selectedIcon);
checkIfLoadedCorrectIcon(selectedIcon, jb, 12, "Selected icon24");
Icon rolloverSelectedIcon = jb.getRolloverSelectedIcon();
assertNotNull(rolloverSelectedIcon);
checkIfLoadedCorrectIcon(rolloverSelectedIcon, jb, 13, "RolloverSelected icon24");
// no pressedSelected
Icon disabledSelectedIcon = jb.getDisabledSelectedIcon();
assertNotNull(disabledSelectedIcon);
checkIfLoadedCorrectIcon(disabledSelectedIcon, jb, 15, "DisabledSelected icon24");
}
示例6: getToolbarPresenter
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getToolbarPresenter() {
if (popupMenu != null) {
JButton button = DropDownButtonFactory.createDropDownButton(
(ImageIcon) getValue(SMALL_ICON),
popupMenu
);
button.putClientProperty("hideActionText", Boolean.TRUE); //NOI18N
button.setAction(this);
return button;
} else {
return new JButton(this);
}
}
示例7: setNodes
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Sets the right set of nodes to display
* @param offset Index of the first node to show
*/
private void setNodes(int offset) {
nodesPanel.removeAll();
for (int i=offset; i<nodes.size() && i < offset + MAX_NODE_COUNT; i++) {
DTNHost h = nodes.get(i);
JButton jb = new JButton(h.toString());
jb.putClientProperty(HOST_KEY, h);
jb.addActionListener(this);
nodesPanel.add(jb);
}
revalidate();
repaint();
}
示例8: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
public JButton createButton(Action a)
{
JButton b = new JButton();
b.putClientProperty("displayActionText", Boolean.TRUE);
b.setAction(a);
return b;
}
示例9: SecurePasswordInputPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private SecurePasswordInputPanel() {
super(new GridLayout(0, 1));
this.passwordField = new JPasswordField(10);
passwordField.setEditable(false);
add(passwordField);
Set<Integer> rows = new HashSet<Integer>(KEYS_MAP.keySet());
final int n = rows.size();
SecureRandom random = new SecureRandom();
while (!rows.isEmpty()) {
int row = random.nextInt() % n;
if (!rows.contains(row)) {
continue;
}
String[] keys = KEYS_MAP.get(row);
rows.remove(row);
JPanel panel = new JPanel();
for (int column = 0; column < keys.length; column++) {
String text = keys[column];
JButton button = new JButton(text);
button.setFont(button.getFont().deriveFont(Font.TRUETYPE_FONT));
if (CLEAR.equalsIgnoreCase(text)) {
button.setBackground(Color.red);
} else if (CAPS.equalsIgnoreCase(text) || BACKSPACE.equalsIgnoreCase(text)) {
button.setBackground(Color.lightGray);
} else {
buttons.add(button);
}
button.putClientProperty("key", text);
button.addActionListener(new MyActionListener());
panel.add(button);
} // end for
add(panel);
} // end while(!rows.isEmpty())
//setVisible(true);
}