Example usage for javax.swing AbstractButton getClientProperty

List of usage examples for javax.swing AbstractButton getClientProperty

Introduction

In this page you can find the example usage for javax.swing AbstractButton getClientProperty.

Prototype

public final Object getClientProperty(Object key) 

Source Link

Document

Returns the value of the property with the specified key.

Usage

From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java

/**
 * Selects the appropriate button in {@link #chartTypeButtonGroup}.
 * //from  w  w  w  .j  a  v a 2  s.c om
 * @param type The type of chart to select the button of.
 */
private void setSelectedChartType(ChartType type) {
    for (Enumeration<AbstractButton> buttons = chartTypeButtonGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton b = buttons.nextElement();
        ChartType ct = (ChartType) b.getClientProperty(CHART_TYPE_PROP_KEY);
        if (ct == type) {
            chartTypeButtonGroup.setSelected(b.getModel(), true);
            return;
        }
    }
    throw new IllegalArgumentException("I can't find a button for chart type " + type);
}

From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java

private ChartType getSelectedChartType() {
    for (Enumeration<AbstractButton> buttons = chartTypeButtonGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton b = buttons.nextElement();
        if (chartTypeButtonGroup.isSelected(b.getModel())) {
            ChartType ct = (ChartType) b.getClientProperty(CHART_TYPE_PROP_KEY);
            logger.debug("Found selected chart type " + ct);
            return ct;
        }/*  ww w .ja  v  a2s  .  co m*/
    }

    logger.debug("Didn't find any selected chart buttons. Returning null.");
    return null;
}