Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (C) 2006 Sun Microsystems, Inc. All rights reserved. Use is
  * subject to license terms.
 package examples;
A simple demonstration of the @Action(selectedProperty) annotation parameter. The selectedProperty parameter names a bound boolean property whose value is kept in sync with the value of the corresponding ApplicationAction's selectedProperty, which in turn mirrors the value of JToggleButtons that have been configured with that ApplicationAction.

Hans Muller (Hans.Muller@Sun.COM)
    private static final String SELECTED_KEY = "SwingSelectedKey";
    private boolean selected = false;
    JCheckBox checkBox = null;
    JButton button = null;
    JRadioButton radioButton = null;
    JTextArea textArea = null;
    @Override protected void startup() {
        ActionMap actionMap = getContext().getActionMap();
         = new JRadioButton(actionMap.get("toggleAction"));
         = new JCheckBox(actionMap.get("toggleAction"));
         = new JButton(actionMap.get("buttonAction"));
         = new JTextArea();
        JPanel controlPanel = new JPanel();
        JPanel mainPanel = new JPanel(new BorderLayout());
        mainPanel.add(new JScrollPane(), .);
    @Action public void buttonAction() {
    @Action(selectedProperty = "selected"public void toggleAction() {
    public boolean isSelected() { 
    public void setSelected(boolean selected) {
        boolean oldValue = this.;
        this. = selected;
        String msg = 
            String.format("%s.setSelected(%s)\n"getClass().getName(), this.) + 
            String.format("checkBox.getAction().isSelected() %s\n"cba.isSelected()) + 
            String.format("checkBox.isSelected() %s\n".isSelected()) + 
            String.format("radioButton.isSelected() %s\n".isSelected());
        .append(msg + "\n");
    public static void main(String[] args) {
New to GrepCode? Check out our FAQ X