public RemoveListenerExample() {

		JPanel panel = new JPanel();

		panel.setLayout(null);

		add = new JButton("+");
		add.setBounds(40, 30, 80, 25);
		buttonlistener = new ButtonListener();

		active = new JCheckBox("Active listener");
		active.setBounds(160, 30, 140, 25);

		active.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent event) {
				if (active.isSelected()) {
					add.addActionListener(buttonlistener);
				} else {
					add.removeActionListener(buttonlistener);
				}
			}
		});

		text = new JLabel("0");
		text.setBounds(40, 80, 80, 25);

		panel.add(add);
		panel.add(active);
		panel.add(text);

		add(panel);

		setTitle("Remove listener");
		setSize(310, 200);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
	}