Example usage for javax.swing JToggleButton getModel

List of usage examples for javax.swing JToggleButton getModel

Introduction

In this page you can find the example usage for javax.swing JToggleButton getModel.

Prototype

public ButtonModel getModel() 

Source Link

Document

Returns the model that this button represents.

Usage

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);// w w w.  j  a  v  a 2  s  .c  o  m

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}