I've recently found swingx and wanted to experiment with JXCollapsiblePane. But i cant get it to work. I've found this code:
Action toggleAction = collapsiblePane.getActionMap().
get(JXCollapsiblePane.TOGGLE_ACTION);
toggleButton.setAction(toggleAction);
But clicking button does nothing. If i set pane collapsed initially, when clicking button, pane closes WITHOUT animation, and subsequent clicks do nothing. Im horrible at programming please give some advice.
EDIT I use IDE Netbeans to drag'n'drop component into the frame
collapsiblePane = new org.jdesktop.swingx.JXCollapsiblePane();
collapsiblePane.setCollapsed(true);
EDIT2 Ok the problem was it was set to toggle UP, but there was no place to collapse, i changed it to RIGHT and kinda works but still no animation. I tried to just create frame and pane manually and it works just fine. I guess the problem is in the way gui plugin adds collapsiblepane to frame.
Maybe someone with expirience in working with JXCollapsiblePane and Netbeans could help
EDIT3
When the collapsiblePane opens other stuff on the frame is not moving. I create pane from gui builder, place JPanel in it, some buttons and text fields in panel; and label and button from code:
initComponents();
setLayout(new BorderLayout());
add(new JLabel("JLabelFromCode", JLabel.CENTER));
JPanel buttonPanel = new JPanel();
add(buttonPanel, BorderLayout.SOUTH);
collapsingButtonFromCode = new JButton();
collapsingButtonFromCode.setText("toggleButtonFromCode");
buttonPanel.add(collapsingButtonFromCode);
buttonFromCode.addActionListener(collapsiblePane.getActionMap().get(
JXCollapsiblePane.TOGGLE_ACTION));
collapsingButtonFromCode.addActionListener(collapsiblePane.getActionMap().get(
JXCollapsiblePane.TOGGLE_ACTION));
setVisible(true);
initComponents() is the method created by IDE which defines layout, i cant edit it, and i think this method is the problem:
java.awt.GridBagConstraints gridBagConstraints;
buttonFromCode = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
collapsiblePane = new org.jdesktop.swingx.JXCollapsiblePane();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
buttonFromCode.setText("CollapseButtonFromGuiBuilder");
jLabel1.setText("jLabel1");
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jButton1.setText("jButton1");
jLabel2.setText("jLabel2");
jLabel3.setText("jLabel3");
jTextField1.setText("jTextField1");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jButton1)
.addGap(76, 76, 76)
.addComponent(jLabel2)
.addGap(186, 186, 186)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(193, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(337, Short.MAX_VALUE)
.addComponent(jLabel3)
.addGap(296, 296, 296))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel3)
.addContainerGap(22, Short.MAX_VALUE))
);
collapsiblePane.getContentPane().add(jPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonFromCode, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44))
.addComponent(collapsiblePane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 661, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(collapsiblePane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonFromCode)
.addComponent(jLabel1))
.addContainerGap(22, Short.MAX_VALUE))
);
pack();
}// </editor-fold>