NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi John, > I have added a LabeledColorWidget onto a JPanel. Depending on which color > map the user chooses, I would like to remove the current widget from the > panel and add another one in its place. I have been using the following code: > > public void actionPerformed(ActionEvent e) > { > scaleAllScaleButtonSelect(false); > JRadioButton tempButton = (JRadioButton)e.getSource(); > tempButton.setSelected(true); > jPanel1.remove(0); > > > jPanel1.add(client.getColorWidget(((JRadioButton)e.getSource()).getText()),0); > jPanel1.repaint(); > } > > However, after I remove the first widget the second widget does not appear > on my panel. I know it is there because if the actionPerformed is called > again, other components will not be removed (at the 0th position of the > panel). Is there something about the widget that I need to know > about? Does anyone have any suggestions? visad/benjamin/Galaxy.java does this successfully, with code: widget_panel.remove(lw2) widget_panel.add(lw5, 0); where lw2 and lw5 are LabeledColorWidgets. This is only slightly different from your code, but perhaps that is the critical difference. Good luck, Bill
visad
archives: