Example usage for javax.swing JRadioButton putClientProperty

List of usage examples for javax.swing JRadioButton putClientProperty

Introduction

In this page you can find the example usage for javax.swing JRadioButton putClientProperty.

Prototype

public final void putClientProperty(Object key, Object value) 

Source Link

Document

Adds an arbitrary key/value "client property" to this component.

Usage

From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java

private void initComponents() {

    setLayout(new BorderLayout());

    // create button panel
    JPanel topPanel = new JPanel();
    btnTreeView = new JRadioButton("Tree");
    btnTreeView.putClientProperty("cv.cardName", TREEPANEL);
    btnTableView = new JRadioButton("Table");
    btnTableView.putClientProperty("cv.cardName", TABLEPANEL);

    ActionListener btnListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // show the right layout panel
            String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName");
            if (v != null)
                ((CardLayout) contentPanel.getLayout()).show(contentPanel, v);
        }//from  www  .  j  av a2 s .  c  om
    };
    btnTableView.addActionListener(btnListener);
    btnTreeView.addActionListener(btnListener);

    // connect buttons
    ButtonGroup group = new ButtonGroup();
    group.add(btnTreeView);
    group.add(btnTableView);
    topPanel.setLayout(new MigLayout("", "[64px][55px][62px][grow]", "[][23px]"));

    lblViewAllThe = new JLabel(
            "<html>View all the component series that combine to create the current series. Series can be viewed as:");
    topPanel.add(lblViewAllThe, "cell 0 0 4 1");
    JRadioButton btnTree2View = new JRadioButton("Flow chart");
    btnTree2View.putClientProperty("cv.cardName", TREE2PANEL);
    btnTree2View.addActionListener(btnListener);
    group.add(btnTree2View);
    topPanel.add(btnTree2View, "cell 0 1,alignx left,aligny center");
    topPanel.add(btnTreeView, "cell 1 1,alignx left,aligny center");
    topPanel.add(btnTableView, "cell 2 1,alignx left,aligny center");

    topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));

    add(topPanel, BorderLayout.NORTH);

    // create status bar
    JPanel status = new JPanel();
    status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
    txtStatus = new JLabel("");
    pbStatus = new JProgressBar();
    pbStatus.setVisible(false);
    status.add(txtStatus);
    status.add(Box.createHorizontalStrut(8));
    status.add(pbStatus);
    status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    add(status, BorderLayout.SOUTH);

    contentPanel = new JPanel(new CardLayout());
    add(contentPanel, BorderLayout.CENTER);

    tablePanel = new JPanel(new BorderLayout());
    setupTable();
    tablePanel.add(new JScrollPane(table), BorderLayout.CENTER);

    treePanel = new JPanel(new BorderLayout());
    setupTree();
    treePanel.add(new JScrollPane(tree), BorderLayout.CENTER);

    tree2Panel = new JPanel(new BorderLayout());
    setupTreeGUI();

    contentPanel.add(tablePanel, TABLEPANEL);
    contentPanel.add(treePanel, TREEPANEL);
    contentPanel.add(tree2Panel, TREE2PANEL);

}