20 this.currentAssets = assets;
21 setLayout(
new BorderLayout());
25 JPanel leftPanel =
new JPanel(
new BorderLayout());
26 leftPanel.setPreferredSize(
new Dimension(200, 0));
28 JPanel toolbar =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
29 JButton addBtn =
new JButton(
"Add " +
type);
30 addBtn.addActionListener(e -> {
32 if (fc.showOpenDialog(
this) == JFileChooser.APPROVE_OPTION) {
33 File file = fc.getSelectedFile();
36 Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
39 }
catch (Exception ex) {
41 JOptionPane.showMessageDialog(
this,
"Error copying asset: " + ex.getMessage());
47 leftPanel.add(toolbar, BorderLayout.NORTH);
48 leftPanel.add(
new JScrollPane(
list), BorderLayout.CENTER);
50 previewLabel.setBorder(BorderFactory.createTitledBorder(
"Preview"));
52 list.addListSelectionListener(e -> {
53 if (!e.getValueIsAdjusting() &&
list.getSelectedIndex() != -1) {
58 add(leftPanel, BorderLayout.WEST);
77 if (
type.equals(
"Costume")) {
79 ImageIcon icon =
new ImageIcon(file.getAbsolutePath());
80 Image img = icon.getImage();
82 int w = img.getWidth(
null);
83 int h = img.getHeight(
null);
84 double scale = Math.min(400.0 / w, 400.0 / h);
85 if (scale > 1.0) scale = 1.0;
87 Image scaled = img.getScaledInstance((
int)(w * scale), (
int)(h * scale), Image.SCALE_SMOOTH);
90 }
catch (Exception e) {