A few years back, I struggled with including a JPlaylist in a custom popup. In short, the problem was that once you had used the "add" button in the JPlaylist component, it became unresponsive, for example, when trying to use it for the next object. It took a "close and reopen" of the project to shake it loose.
At the time, I was using some ancient frame code, and finally found a workaround. But David suggested using a JDialog instead of a frame. That old thread, from this post down:
https://jalbum.net/forum/thread.jspa?messageID=324573#324573
Fast forward to today, and that's what I'm doing with my custom popups - using a dialog box. Works beautifully, except with a JPlaylist, which exhibits the old bad behavior. No problem with saving or retrieving the entries, but after you've used it once, you can't use it again.
Attached is a very skeletal skin. Add a few images. Go into edit mode for the first image and add some music tracks (in the real world, this would be restricted to folders, but I wanted to keep this as stripped-down as possible). OK out of the popup, and move to the next image. Try to add music tracks. You can't. Close and reopen, and it's fine again.
Here's the entire code for the custom UI:
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import se.datadosen.component.*;
import se.datadosen.jalbum.JAlbumContext;
import se.datadosen.jalbum.JCustomPanel;
class JPtestCustom extends JCustomPanel {
JButton popupButton = new JButton("Local Music Tracks");
JPlaylist mtracks = new JPlaylist();
String popupTitle;
public JPtestCustom(JAlbumContext context) {
super(context);
setOpaque(false);
add("center", popupButton);
ControlPanel popup = new ControlPanel() {
{
add(mtracks);
}
};
popupButton.addActionListener((ActionEvent e) -> {
popupTitle = "Music Tracks for: " + currentAO.getName();
JOptionPane.showMessageDialog(context.getExplorer(), popup, popupTitle, JOptionPane.INFORMATION_MESSAGE);
});
init();
}
}
Anyone have a clue about how to shake the JPlaylist loose following a close of the dialog box?
ETA: All source files bundled with the skin.