I have a problem with my exercise for university. I need to create a JList and put there a few elements (just a simple text) without using any collections nor arrays. It's quite silly because a JList is usually initialized with DefaultListModel (it's a collection too), but in this case I'm not allowed to use it. I tried to put a JLabel object in a parametrized constructor of JList but it doesn't work. Do anyone of you have an idea how to deal with it? Much thanks for help in advance.
My code so far:
JFrame jFrame = new JFrame("title");
JList<String> jList = new JList<>();
jList.add(new JLabel("label1"));
jFrame.add(jList);
jFrame.setSize(500, 500);
jFrame.setVisible(true);