Проблема с переносом данных во второе окно Java

такая проблема. Пытаюсь перенести данные возникает такая ошибка

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: Unhandled exception type MalformedURLException The constructor create(templates.Position[], String[], Font[]) is undefined

Вот мой код откуда я запускаю

import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ImageIcon;
import java.awt.Color;

public class templates extends JFrame {

private static final long serialVersionUID = 1L;
private JPanel contentPane;

private String[][] textsArray = {
        {"Text 1 for the first panel", "Text 2 for the first panel"},
        {"Text 1 for the second panel", "Text 2 for the second panel", "Text 3 for the second panel"},
        {"Text 1 for the third panel"},
};

private Font[][] fontsArray = {
        {new Font("Arial", Font.PLAIN, 12), new Font("Arial", Font.BOLD, 14)},
        {new Font("Times New Roman", Font.ITALIC, 16), new Font("Arial", Font.PLAIN, 12), new Font("Arial", Font.BOLD, 14)},
        {new Font("Arial", Font.BOLD, 18)},
};

private Position[][] positionsArray = {
        {new Position(10, 20), new Position(50, 30)}, // Positions for the first panel
        {new Position(30, 40), new Position(60, 70)}, // Positions for the second panel
};

private URL[] imageUrls = {
        new URL("https://i.postimg.cc/Hs8cBjkP/semestralka.jpg"),
        new URL("https://i.postimg.cc/Hs8cBjkP/semestralka.jpg"),
};


/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(() -> {
        try {
            templates frame = new templates();
            frame.setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}

/**
 * Create the frame.
 */
public templates() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

    setContentPane(contentPane);
    contentPane.setLayout(new GridLayout(3, 3, 0, 0));

    for (int i = 0; i < 6; i++) {
        JPanel panel = createTemplatePanel(i);
        contentPane.add(panel);
    }
}

private JPanel createTemplatePanel(final int index) {
    JPanel panel = new JPanel();
    panel.setBorder(new LineBorder(Color.BLUE, 2));
    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            dispose();
            try {
                ImageIcon backgroundImage = new ImageIcon(imageUrls[index]);
                create newWindow = new create(positionsArray[index], textsArray[index], fontsArray[index]);
                newWindow.setBackgroundImage(backgroundImage);
                newWindow.setVisible(true);
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
            }
        }
    });
    return panel;
}

public class Position {
    private int x;
    private int y;

    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }

    // Getters and setters
    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}

}

Буду благодарен за любую помощь!


Ответы (0 шт):