Example usage for javax.swing JPanel isVisible

List of usage examples for javax.swing JPanel isVisible

Introduction

In this page you can find the example usage for javax.swing JPanel isVisible.

Prototype

@Transient
public boolean isVisible() 

Source Link

Document

Determines whether this component should be visible when its parent is visible.

Usage

From source file:Main.java

/**
 * Creates a panel that contains all of the components on top of each other in north,
 * and tries to make them as small as possible (probably by using getPreferredSize()).
 *
 * @deprecated use proper layout, usually no need to use such complex/ugly layouting
 *///from   ww w  . java2  s.  c  om
public static JPanel combineInNorth(JComponent[] components) {
    JPanel result = new JPanel();
    if (components.length == 0) {
        return result;
    }
    result.setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    result.add(contentPanel, BorderLayout.NORTH);
    contentPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.weightx = 1.0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    for (int i = 0; i < components.length; i++) {
        contentPanel.add(components[i], constraints);
    }
    if (result.isVisible())
        result.doLayout();
    return result;
}

From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java

private JPanel getNorthPanel() {
    JPanel ret = new JPanel();
    ret.setLayout(new BorderLayout());
    JPanel pnlTextFilter = new JPanel();
    CRFlowLayout layout = new CRFlowLayout();
    layout.setAlignment(CRFlowLayout.LEFT);
    pnlTextFilter.setLayout(layout);// w ww . j a v  a 2 s  .co  m
    txtFilter = new JButtonTextField();
    txtFilter.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doFilter();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doFilter();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doFilter();
        }
    });
    pnlTextFilter.add(txtFilter);
    btnToggleFilters = new JToggleButton(OrbisGISIcon.FILTER);
    btnToggleFilters.setMargin(new Insets(0, 0, 0, 0));
    btnToggleFilters.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pnlFilters.setVisible(!pnlFilters.isVisible());
        }
    });
    btnToggleFilters.setBorderPainted(false);
    btnToggleFilters.setContentAreaFilled(false);
    pnlTextFilter.add(btnToggleFilters);
    ret.add(pnlTextFilter, BorderLayout.NORTH);
    JPanel pnlFilters = getFilterAndTagPanel();
    ret.add(pnlFilters, BorderLayout.CENTER);
    return ret;
}

From source file:org.ut.biolab.medsavant.client.query.QueryViewController.java

private List<JComponent> getComponentsFromQueryModel(SearchConditionGroupItem g, int depth) {
    List<JComponent> components = new ArrayList<JComponent>();
    int w = 0;/*from   www.j  ava  2 s  .  c o m*/
    for (final SearchConditionItem item : g.getItems()) {
        if (item instanceof SearchConditionGroupItem) {
            String addition = "";
            if (item.getParent() != null) {
                addition = item.getRelation() + "";
            }

            final JPanel p = ViewUtil.getClearPanel();
            MigLayout ml = new MigLayout("wrap 1, hidemode 1, insets 2");
            p.setLayout(ml);
            Border border = ViewUtil.getThickLeftLineBorder();
            p.setBorder(border);

            final PillView pv = new PillView(true);
            pv.indent(depth);

            pv.setActivated(true);

            final ActionListener toggleGroupExpand = new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    expandedItemsMap.put((SearchConditionGroupItem) item, !p.isVisible());
                    p.setVisible(!p.isVisible());
                    pv.setText(getGroupTitle((SearchConditionGroupItem) item));
                }
            };

            pv.setExpandListener(toggleGroupExpand);

            pv.setPopupGenerator(new ConditionPopupGenerator() {
                @Override
                public JPopupMenu generatePopup() {
                    final SearchConditionGroupItem groupItem = (SearchConditionGroupItem) item;
                    final JPopupMenu m = new JPopupMenu();

                    if (!item.getParent().isFirstItem(item)) {
                        if (item.getRelation() == QueryRelation.AND) {
                            JMenuItem b = new JMenuItem("Change to \"or\"");
                            b.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent ae) {
                                    item.setRelation(QueryRelation.OR);
                                    pv.setText(getGroupTitle(groupItem));
                                }
                            });
                            m.add(b);
                        } else {
                            JMenuItem b = new JMenuItem("Change to \"and\"");
                            b.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent ae) {
                                    item.setRelation(QueryRelation.AND);
                                    pv.setText(getGroupTitle(groupItem));
                                }
                            });
                            m.add(b);
                        }
                    }

                    JMenuItem delgroup = new JMenuItem("Delete");
                    delgroup.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent ae) {
                            groupItem.getParent().removeItem(groupItem);
                            refreshView();
                            expandedItemsMap.remove((SearchConditionGroupItem) item);
                        }
                    });
                    m.add(delgroup);

                    return m;
                }
            });
            SearchConditionGroupItem g2 = (SearchConditionGroupItem) item;

            pv.setText(getGroupTitle(g2));
            Boolean exp = expandedItemsMap.get((SearchConditionGroupItem) item);

            if (exp == null) {
                p.setVisible(false);
                pv.collapse();
            } else {
                p.setVisible(true);
                pv.expand();
            }

            components.add(pv);
            for (JComponent c : getComponentsFromQueryModel((SearchConditionGroupItem) item, depth + 1)) {
                p.add(c, "left");
            }
            components.add(p);

            w = pv.getMaximumSize().width;
        } else {
            SearchConditionItemView sciv = itemToViewMap.get(item);
            ((PillView) sciv).indent(depth);
            w = sciv.getMaximumSize().width;
            sciv.refresh();
            components.add(sciv);
        }
    }

    if (w == 0) {
        w = BOTTOM_SEARCH_TEXTFIELD_WIDTH;
    }
    JComponent c = getInputFieldForGroup(g, w);
    components.add(c);
    return components;
}

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

public void toggleDetailVisibility(String key) {
    JPanel p = keyDetailComponentMap.get(key);
    toggleDetailVisibility(key, !p.isVisible());
}