JXCollapsiblePane top = new JXCollapsiblePane() { // @Override // public Dimension getMaximumSize() { // return getPreferredSize(); // } }; top.add(new JLabel("some random label")); top.add(new JLabel("and another")); top.add(new JButton(top.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION))); top.setCollapsed(true); JXFrame frame = new JXFrame("collapsible in top", true); frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS)); frame.add(top, BorderLayout.NORTH); frame.add(new JScrollPane(new JXTable(50, 4))); frame.add(new JButton(top.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION)), BorderLayout.SOUTH); frame.pack(); frame.setVisible(true);
@Override public void actionPerformed(ActionEvent e) { collapsiblePane.setCollapsed(!collapsiblePane.isCollapsed()); } }
/** * Returns the contentPane object for this JXTaskPane. * @return the contentPane property */ public Container getContentPane() { return collapsePane.getContentPane(); }
@Override public void displayChart(final JComponent chart) { _chartContainer.getContentPane().removeAll(); _chartContainer.getContentPane().add(chart); _chartContainer.setCollapsed(false); _chartContainer.updateUI(); } }
boolean oldValue = isCollapsed(); this.collapsed = val; if (isAnimated() && isShowing()) { if (oldValue == isCollapsed()) { return; int preferredDimension = direction.isVertical() ? getContentPane() .getPreferredSize().height : getContentPane().getPreferredSize().width; int delta = Math.max(8, preferredDimension / 10); setAnimationParams(new AnimationParams(30, delta, 0.01f, 1.0f)); animator.reinit(dimension, preferredDimension); wrapper.getView().setVisible(true); } else { int dimension = direction.isVertical() ? wrapper.getHeight() : wrapper.getWidth(); setAnimationParams(new AnimationParams(30, Math.max(8, dimension / 10), 1.0f, 0.01f)); animator.reinit(dimension, 0); wrapper.collapsedState = isCollapsed(); wrapper.getView().setVisible(!isCollapsed()); revalidate(); repaint(); firePropertyChange("collapsed", oldValue, isCollapsed());
public CollapsibleTreePanel(final JComponent treeComponent) { _collapsibleTreePane = new JXCollapsiblePane(JXCollapsiblePane.Direction.LEFT); _collapsibleTreePane.getContentPane().setBackground(WidgetUtils.BG_COLOR_DARK); _collapsibleTreePane.add(treeComponent); _collapsibleTreePane.setAnimated(false); _toggleTreeViewButton = new JButton(imageManager.getImageIcon("images/widgets/tree-panel-collapse.png")); _toggleTreeViewButton.setBorder(null); _toggleTreeViewButton.setOpaque(false); _toggleTreeViewButton.setContentAreaFilled(false); _toggleTreeViewButton.addActionListener(e -> { final boolean collapsed = _collapsibleTreePane.isCollapsed(); if (collapsed) { _toggleTreeViewButton.setIcon(imageManager.getImageIcon("images/widgets/tree-panel-collapse.png")); _toggleTreeViewButton.setBorder(null); } else { _toggleTreeViewButton.setIcon(imageManager.getImageIcon("images/widgets/tree-panel-expand.png")); _toggleTreeViewButton.setBorder(new EmptyBorder(0, 2, 0, 0)); } _collapsibleTreePane.setCollapsed(!collapsed); }); final DCPanel collapseButtonPanel = new DCPanel(); collapseButtonPanel.setOpaque(true); collapseButtonPanel.setBackground(WidgetUtils.BG_COLOR_DARK); collapseButtonPanel.setLayout(new VerticalLayout(4)); collapseButtonPanel.setBorder(null); collapseButtonPanel.add(_toggleTreeViewButton); setLayout(new BorderLayout()); add(_collapsibleTreePane, BorderLayout.CENTER); add(collapseButtonPanel, BorderLayout.EAST); }
private void createUi() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JXCollapsiblePane collapsePane = new JXCollapsiblePane(); new JButton(collapsePane.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION)); collapseButton.setBorderPainted(false); collapseButton.setHideActionText(true); collapsePane.add(jogControlsPanel); add(collapsePane); collapsePane.setCollapsed( !prefs.getBoolean(PREF_JOG_CONTROLS_EXPANDED, PREF_JOG_CONTROLS_EXPANDED_DEF)); collapsePane.addPropertyChangeListener("collapsed", e -> { //$NON-NLS-1$ prefs.putBoolean(PREF_JOG_CONTROLS_EXPANDED, !collapsePane.isCollapsed()); });
/** * Constructs a new JXCollapsiblePane with a {@link JXPanel} as content pane and the specified * direction. * * @param direction * the direction to collapse the container */ public JXCollapsiblePane(Direction direction) { super.setLayout(new BorderLayout()); this.direction = direction; animator = new AnimationListener(); setAnimationParams(new AnimationParams(30, 8, 0.01f, 1.0f)); setContentPane(createContentPane()); setDirection(direction); // add an action to automatically toggle the state of the pane getActionMap().put(TOGGLE_ACTION, new ToggleAction()); }
collapsePane = new JXCollapsiblePane(); collapsePane.setOpaque(false); super.setLayout(new BorderLayout(0, 0)); super.addImpl(collapsePane, BorderLayout.CENTER, -1); collapsePane.addPropertyChangeListener("collapsed", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) {
Direction oldValue = getDirection(); this.direction = direction; getContentPane().setLayout(new VerticalLayout(2)); } else { getContentPane().setLayout(new HorizontalLayout(2)); firePropertyChange("direction", oldValue, getDirection());
wrapper.collapsedState = false; validate(); JXCollapsiblePane.this.firePropertyChange("collapsed", collapseFiringState, false); return; } else { wrapper.collapsedState = true; wrapper.getView().setVisible(false); JXCollapsiblePane.this.firePropertyChange("collapsed", collapseFiringState, true); if (direction.getFixedDirection(getComponentOrientation()) == Direction.DOWN) { wrapper.setViewPosition(new Point(0, wrapper.getView().getPreferredSize().height - newDimension)); } else { bounds = getBounds(); bounds.height = (bounds.height - oldHeight) + newDimension; currentDimension = bounds.height; if (direction.getFixedDirection(getComponentOrientation()) == Direction.RIGHT) { wrapper.setViewPosition(new Point(wrapper.getView().getPreferredSize().width - newDimension, 0)); } else { bounds = getBounds(); bounds.width = (bounds.width - oldWidth) + newDimension; currentDimension = bounds.width; setBounds(bounds); startDimension = newDimension;
if (collapsed != val) { collapsed = val; if (isAnimated()) { if (collapsed) { int dimension = direction.isVertical() ? wrapper.getHeight() : wrapper.getWidth(); setAnimationParams(new AnimationParams(30, Math.max(8, dimension / 10), 1.0f, 0.01f)); animator.reinit(dimension, 0); wrapper.getHeight() : wrapper.getWidth(); int preferredDimension = direction.isVertical() ? getContentPane().getPreferredSize().height : getContentPane().getPreferredSize().width; int delta = Math.max(8, preferredDimension / 10); setAnimationParams(new AnimationParams(30, delta, 0.01f, 1.0f)); animator.reinit(dimension, preferredDimension); animateTimer.start(); revalidate(); repaint(); firePropertyChange("collapsed", !collapsed, collapsed);
private void initComponents() { createComponents(); collapsiblePane.setAnimated(true); collapsiblePane.setCollapsed(true); infoMessageLabel.setOpaque(false); infoMessageLabel.setForeground(Color.BLACK); infoMessageLabel.addMouseListener(new MyMouseListener()); closeButton.setOpaque(false); closeButton.setBorderPainted(false); closeButton.setContentAreaFilled(false); closeButton.setFocusable(false); closeButton.setIcon(closeNormalIcon); closeButton.setRolloverEnabled(true); closeButton.setRolloverIcon(closeRolloverIcon); JComponent c = buildInfoMessagePanel(); c.setOpaque(true); c.setBackground(new Color(0xFFFFE1)); c.setBorder(BorderFactory.createEtchedBorder()); collapsiblePane.add(c, BorderLayout.CENTER); }
private void createComponents() { createSubComponents(); showFavoritesButton = new JButton(showFavoritesAction); minimizeButton = new MinimizeButton(); collapsiblePane = new JXCollapsiblePane(JXCollapsiblePane.Direction.RIGHT); showButton = new JArrowButtonPanel(getPerimeterTitle(), direction); showButton.showIcons(false); header = buildHeader(); header.setVisible(collapsiblePane.isCollapsed()); collapsiblePane.addPropertyChangeListener("collapsed", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { header.setVisible((Boolean) evt.getNewValue()); } }); panel = new MyPanel(); perimetreWidgetListener = new MyPerimetreWidgetListener(); collapseWidgetActionListener = new MyCollapseWidgetActionListener(); favorisPopupMenu = new JPopupMenu(); centerComponent = buildCenter(); }
/** * Returns the collapsed state of this task pane. * * @return {@code true} if the task pane is collapsed; {@code false} * otherwise */ public boolean isCollapsed() { return collapsePane.isCollapsed(); }
public void hideInfoMessage() { collapsiblePane.setCollapsed(true); }
container.setLayout(layout); dragDropContainer = new JXCollapsiblePane(); dragDropContainer.getContentPane().setBackground(Color.white); MigLayout dpMl = new MigLayout("wrap 1, center"); dragDropContainer.getContentPane().setLayout(dpMl); dp.add(l); dragDropContainer.add(dp); dragDropContainer.add(l = new JLabel("or"), "center"); l.setForeground(new Color(100, 100, 100)); JButton chooseButton = new JButton("Choose..."); chooseButton.setFocusable(false); dragDropContainer.add(chooseButton, "center");
/** * Creates a new empty <code>JXTaskPane</code>. */ public JXTaskPane() { collapsePane = new JXCollapsiblePane(); super.setLayout(new BorderLayout(0, 0)); super.addImpl(collapsePane, BorderLayout.CENTER, -1); updateUI(); setFocusable(true); // disable animation if specified in UIManager setAnimated(!Boolean.FALSE.equals(UIManager.get("TaskPane.animate"))); // listen for animation events and forward them to registered listeners collapsePane.addPropertyChangeListener( JXCollapsiblePane.ANIMATION_STATE_KEY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { JXTaskPane.this.firePropertyChange(evt.getPropertyName(), evt .getOldValue(), evt.getNewValue()); } }); }
class ButtonClickActionK implements ActionListener { public void actionPerformed(ActionEvent e) { String str = e.getActionCommand(); Component source = (Component) e.getSource(); switch (str) { case "TextButton": Container parent = source.getParent(); JXCollapsiblePane testp = new JXCollapsiblePane(); testp.add(new JLabel("dummy, just to see we are open")); parent.add(testp); parent.revalidate(); break; default: JOptionPane.showMessageDialog(source, "Erm, this is embarrasing! Something went (horribly) wrong..."); } } } // usage JButton newButton= new JButton("TextButton"); newButton.addActionListener(new ButtonClickActionK()); // note: _not_ using a class field JComponent newPanel = new JPanel(new VerticalLayout()); newPanel.add(newButton);
public static JXCollapsiblePane createCollapsiblePane(final Direction direction) { final JXCollapsiblePane collapsiblePane = new JXCollapsiblePane(direction); collapsiblePane.setOpaque(false); // hack to make it non-opaque! try { final Field field = JXCollapsiblePane.class.getDeclaredField("wrapper"); field.setAccessible(true); final JViewport viewPort = (JViewport) field.get(collapsiblePane); viewPort.setOpaque(false); final JComponent component = (JComponent) viewPort.getView(); component.setOpaque(false); } catch (final Exception e) { logger.info("Failed to make JXCollapsiblePane non-opaque", e); } return collapsiblePane; }