Java Code Examples for org.jdesktop.swingx.JXCollapsiblePane

The following examples show how to use org.jdesktop.swingx.JXCollapsiblePane. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: arcusplatform   Source File: ModelTableView.java    License: Apache License 2.0 7 votes vote down vote up
private void setCollapsed(boolean collapsed) {
   if(!isActive()) {
      return;
   }
   for(Component c: ((JPanel) getComponent()).getComponents()) {
      if(!(c instanceof JPanel)) {
         continue;
      }
      JPanel jp = (JPanel) c;
      if(!(jp.getComponents().length == 2 && jp.getComponents()[1] instanceof JXCollapsiblePane)) {
         continue;
      }
      JXCollapsiblePane collapser = (JXCollapsiblePane) jp.getComponents()[1];
      collapser.setCollapsed(collapsed);
   }
}
 
Example 2
Source Project: darklaf   Source File: DarkTaskPaneUI.java    License: MIT License 4 votes vote down vote up
@Override
protected void installListeners() {
    super.installListeners();
    group.addPropertyChangeListener(JXCollapsiblePane.ANIMATION_STATE_KEY,
                                    e -> isCollapsed = KEY_COLLAPSED.equals(e.getNewValue()));
}
 
Example 3
private void init() {
    setLayout(new BorderLayout());
    for (int i=0; i<no; i++) {
        more[i] = new JComboBox();
    }
    JPanel panel = new JPanel(new GridBagLayout());

    panel.add(new JLabel(I18NSupport.getString("chart.xcolumn")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0), 0, 0));
    panel.add(xComboBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5), 0, 0));
    panel.add(new JLabel(I18NSupport.getString("chart.ycolumn")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0), 0, 0));
    panel.add(yComboBox, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5), 0, 0));


    JXCollapsiblePane cp = new JXCollapsiblePane();
    cp.setCollapsed(true);

    // get the built-in toggle action
    Action toggleAction = cp.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION);
    // use the collapse/expand icons from the JTree UI
    toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon"));
    toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon"));
    JButton toggle = new JButton(toggleAction);
    toggle.setText("");
    toggle.setBorder(BorderFactory.createEmptyBorder());

    cp.setLayout(new GridBagLayout());
    for (int i=0; i<no; i++) {
        cp.add(more[i], new GridBagConstraints(0, i, 1, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(5, 35, 5, 5), 0, 0));
    }
    cp.add(new JXTitledSeparator(""), new GridBagConstraints(0, no, 1, 1, 1.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(10, 0, 5, 140), 0, 0));

    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.X_AXIS));
    headerPanel.add(toggle);
    headerPanel.add(Box.createHorizontalStrut(5));
    headerPanel.add(new JXTitledSeparator(I18NSupport.getString("chart.ycolumn.more")));

    panel.add(headerPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 140), 0, 0));
    panel.add(cp, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 0), 0, 0));

    panel.add(new JLabel(""), new GridBagConstraints(3, 9, 1, 3, 1.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5), 0, 0));

    add(panel, BorderLayout.CENTER);
}