I did extend the compiled FancyBox custom panel with a new field for an URL preceded by a JLabelFor text which looks for the first image as displayed in the attached screenshot CustomPanelImage1.png
But is I select the next image I see the JLabelFor text twice as shown in the attached screenshot CustomPanelImage2.png
A next image shows 3 JLabelFor text etc.
What should be corrected in the next code (src file also enclosed)?
class FancyBoxCustomUI extends JCustomPanel {
AlbumObject cAO;
AlbumObjectProperties cProps;
JCheckBox panoramicSphericalImage = new JCheckBox("Spherical panoramic image", false);
JCheckBox panoramicImage = new JCheckBox("Cylindrical panoramic image", false);
JCheckBox pan360 = new JCheckBox("<html>360° panorama</html>", false);
JSmartTextField moreInfoURL = new JSmartTextField();
public void setAlbumObject(AlbumObject ao) {
super.setAlbumObject(ao);
removeAll();
if (ao != null) {
cAO = ao;
cProps = cAO.getProperties();
File currentContextFile = ao.getFile();
boolean isFolder = cAO.getCategory() == Category.folder;
boolean isImage = cAO.getCategory() == Category.image;
if (isFolder) {
add(new JLabelFor("URL for 'More info' button:", moreInfoURL));
add("br hfill", moreInfoURL);
moreInfoURL.setEnabled(isFolder);
} else if (isImage) {
add("br", panoramicSphericalImage);
add("br", panoramicImage);
add("br", pan360);
panoramicSphericalImage.setEnabled(isImage);
panoramicImage.setEnabled(isImage);
pan360.setEnabled(isImage);
pan360.setEnabled(panoramicImage.isSelected());
} else {
// close and remove the custom panel, how should I do that?
return;
}
loadUI();
}
}
public FancyBoxCustomUI(JAlbumContext context) {
super(context);
// Set up the UI
setBackground(SystemColor.text);
setOpaque(true);
panoramicSphericalImage.setBackground(SystemColor.text);
panoramicImage.setBackground(SystemColor.text);
pan360.setBackground(SystemColor.text);
pan360.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cProps.save();
}
}
);
panoramicSphericalImage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (panoramicSphericalImage.isSelected()) {
panoramicImage.setSelected(false);
pan360.setEnabled(false);
cProps.remove("maxImageWidth");
cProps.remove("panoramicImage");
cProps.remove("pan360");
}
cProps.save();
}
}
);
// Enable maxImageWidth field if panoramicImage is checked, otherwise remove userVariables
panoramicImage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (panoramicImage.isSelected()) {
panoramicSphericalImage.setSelected(false);
cProps.put("maxImageWidth", "50000");
} else {
cProps.remove("maxImageWidth");
cProps.remove("panoramicImage");
cProps.remove("pan360");
}
cProps.save();
pan360.setEnabled(panoramicImage.isSelected());
}
}
);
init();
}
}
Edit: File FancyBoxCustomUi.java enclosed
Edited by: AndreWolff on 03-Dec-2020 19:03
Edit: code updated,
Edited by: AndreWolff on 06-Dec-2020 11:46