How can I successfully work with multiple Default List Models in Java?

35 Views Asked by At

firstly, thank you for any help in advance.

I'm working on a personal project while in school - I would like to make a Table Top System Manager that my wife and I can use to run our homebrewed systems.

Current Road-Block: Working with multiple Default List Models.

Here's how I'm trying to define them at the moment:

public class GameGuideMain extends javax.swing.JFrame {
    private DefaultListModel<Player> playerList;
    private DefaultListModel<Creature> creatureList;
    private DefaultListModel<NPC> npcList;
    
    public GameGuideMain() {
        //Character Default List Models
        //Player
        playerList = new DefaultListModel<Player>();
        //Creature
        creatureList = new DefaultListModel<Creature>();
        //NPC
        npcList = new DefaultListModel<NPC>();

Each of these values extend from Character - I originally tried to define these separate list models as all value, but continued to get red so I tried it this way.

While this did get rid of the Red - I originally faced - now my issue is how would I convert a value type of Character to Player when Player is already extending Character?

My expected result is that these would each be able to add to their respective characterList(s)

A JFrame that includes a label and 3 panels that hold JLists

0

There are 0 best solutions below