package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;

public final class MainPanel extends JPanel {
    private final JRadioButton r0 = new JRadioButton("DISCONTIGUOUS_TREE_SELECTION", true);
    private final JRadioButton r1 = new JRadioButton("SINGLE_TREE_SELECTION");
    private final JRadioButton r2 = new JRadioButton("CONTIGUOUS_TREE_SELECTION");
    private final ButtonGroup bg = new ButtonGroup();
    private final JTree tree = new JTree();
    public MainPanel() {
        super(new BorderLayout());

        ActionListener al = e -> {
            JRadioButton rb = (JRadioButton) e.getSource();
            if (rb.equals(r2)) {
                tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
            } else if (rb.equals(r1)) {
                tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            } else {
                tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
            }
        };
        Box p = Box.createVerticalBox();
        for (AbstractButton b: Arrays.asList(r0, r1, r2)) {
            b.addActionListener(al);
            bg.add(b);
            p.add(b);
        }
        add(p, BorderLayout.NORTH);
        add(new JScrollPane(tree));
        setPreferredSize(new Dimension(320, 240));
    }

    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

@@ -266,184 +266,100 @@
 ate 
-final JRadioButton r0 = new JRadioButton(%22DISCONTIGUOUS_TREE_SELECTION%22, true
+MainPanel() %7B%0A        super(new BorderLayout()
 );%0A
+%0A
     
-private final JRadioButton r1 = new JRadioButton(%22SINGLE_TREE_SELECTION%22
+    JTree tree = new JTree(
 );%0A
+%0A
     
-private final
+   
  JRa
@@ -369,17 +369,17 @@
 Button r
-2
+0
  = new J
@@ -391,16 +391,19 @@
 Button(%22
+DIS
 CONTIGUO
@@ -424,178 +424,227 @@
 ION%22
+, true
 );%0A    
-private final ButtonGroup bg = new ButtonGroup();%0A    private final JTree tree = new JTree();%0A    public MainPanel() %7B%0A        super(new BorderLayout()
+    r0.addItemListener(e -%3E %7B%0A            if (e.getStateChange() == ItemEvent.SELECTED) %7B%0A                tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
 );%0A
-%0A
         
 Acti
@@ -643,39 +643,27 @@
     
-ActionListener al = e -%3E %7B%0A    
+    %7D%0A        %7D);%0A%0A
     
@@ -684,13 +684,16 @@
 on r
-b = (
+1 = new 
 JRad
@@ -704,54 +704,125 @@
 tton
-) e.getSource();%0A            if (rb.equals(r2)
+(%22SINGLE_TREE_SELECTION%22);%0A        r1.addItemListener(e -%3E %7B%0A            if (e.getStateChange() == ItemEvent.SELECTED
 ) %7B%0A
@@ -898,26 +898,22 @@
 onModel.
-CONTIGUOUS
+SINGLE
 _TREE_SE
@@ -939,34 +939,8 @@
    %7D
- else if (rb.equals(r1)) %7B
 %0A   
@@ -940,32 +940,37 @@
   %7D%0A        
+%7D);%0A%0A
         
 tree.getSele
@@ -961,75 +961,54 @@
     
-tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE
+JRadioButton r2 = new JRadioButton(%22CONTIGUOUS
 _TRE
@@ -1010,32 +1010,33 @@
 S_TREE_SELECTION
+%22
 );%0A            %7D
@@ -1034,18 +1034,91 @@
     
-    %7D else
+r2.addItemListener(e -%3E %7B%0A            if (e.getStateChange() == ItemEvent.SELECTED)
  %7B%0A 
@@ -1185,35 +1185,32 @@
 eSelectionModel.
-DIS
 CONTIGUOUS_TREE_
@@ -1244,17 +1244,19 @@
        %7D
-;
+);%0A
 %0A       
@@ -1285,24 +1285,68 @@
 ticalBox();%0A
+        ButtonGroup bg = new ButtonGroup();%0A
         for 
@@ -1397,45 +1397,8 @@
 ) %7B%0A
-            b.addActionListener(al);%0A
     

use ItemListener instead of ActionListener for JRadioButton