Java Code Examples for javax.swing.JButton.putClientProperty()

The following are Jave code examples for showing how to use putClientProperty() of the javax.swing.JButton class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: TerminalSupportImpl.java   Source Code and License Vote up 7 votes
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;
}
 
Example 2
Project: incubator-netbeans   File: ActionsTest.java   Source Code and License Vote up 6 votes
/**
 * 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");
}
 
Example 3
Project: incubator-netbeans   File: TerminalContainerCommon.java   Source Code and License Vote up 5 votes
private JButton adjustButton(JButton b) {
    b.setBorderPainted(false);
    b.setOpaque(false);
    b.setText(null);
    b.putClientProperty("hideActionText", Boolean.TRUE);	// NOI18N
    // NOI18N
    return b;
}
 
Example 4
Project: incubator-netbeans   File: RunScriptAction.java   Source Code and License Vote up 5 votes
@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);
    }
}
 
Example 5
Project: incubator-netbeans   File: ActionsTest.java   Source Code and License Vote up 5 votes
/**
 * 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");
}
 
Example 6
Project: incubator-netbeans   File: NavigationHistoryBackAction.java   Source Code and License Vote up 5 votes
@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);
    }
}
 
Example 7
Project: incubator-netbeans   File: NavigationHistoryForwardAction.java   Source Code and License Vote up 5 votes
@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);
    }
}
 
Example 8
Project: the-one-mdonnyk   File: NodeChooser.java   Source Code and License Vote up 5 votes
/**
 * 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();
}
 
Example 9
Project: Bachelor-Thesis   File: NodeChooser.java   Source Code and License Vote up 5 votes
/**
 * 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();
}
 
Example 10
Project: hml   File: TreePanel.java   Source Code and License Vote up 5 votes
public JButton createButton(Action a) 
{ 
 	JButton b = new JButton(); 
 
 	b.putClientProperty("displayActionText", Boolean.TRUE); 
 	b.setAction(a); 
 	
 	return b; 
}
 
Example 11
Project: hml   File: MyPanel.java   Source Code and License Vote up 5 votes
public JButton createButton(Action a) 
{ 
 	JButton b = new JButton(); 
 
 	b.putClientProperty("displayActionText", Boolean.TRUE); 
 	b.setAction(a); 
 	
 	return b; 
}
 
Example 12
Project: xitk   File: SecurePasswordInputPanel.java   Source Code and License Vote up 4 votes
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);
}