0
    try{
        String[] mobileSuit;
        File packageFile = openDialogFile("Select", "Choose folder that contain overall mobile suit folder", JFileChooser.DIRECTORIES_ONLY);
        mobileSuit = packageFile.list();
        DefaultListModel<String> listModel = new DefaultListModel<>();
        for(String el : mobileSuit){
            listModel.addElement(el);
        }
        this.packagePath = packageFile.getPath();
        JList_mobileSuit.setModel(listModel);
        JList_mobileSuit.setSelectedIndex(0);
    }catch(java.lang.NullPointerException e){

    }

When i uncomment " JList mobileSuit.setModel(listModel) " line,netbeans's output that report "TestUI.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. " .I'm still confused as to what I am doing wrong.Please help me

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    JList_mobileSuit is a javax.swing.JList and when i use DefaultListModel listModel = new DefaultListModel(); netbeans report "redundant type arguments in new expression (use diamond operator instead) " – user1654082 Sep 07 '12 at 07:58

1 Answers1

1

it shoud be

DefaultListModel<String> listModel = new DefaultListModel<String>();

and JList can take String too

JList<String> JList_mobileSuit = new JList<>(listModel);//JList<String>(listModel);
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Note [*Type Inference for Generic Instance Creation*](http://docs.oracle.com/javase/7/docs/technotes/guides/language/type-inference-generic-instance-creation.html), new in Java 7. – trashgod Sep 07 '12 at 10:51