Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.posted.palinacquisition!news.posted.palinacquisition.POSTED!not-for-mail NNTP-Posting-Date: Fri, 16 Dec 2011 00:03:43 -0600 Date: Thu, 15 Dec 2011 22:03:42 -0800 From: Peter Duniho User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Generics ? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 52 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 50.46.118.188 X-Trace: sv3-LPwSuguyJJ/0gx5tLX/Zqin0Kcf437wQOwJmG/oS3CFx0sH51YbZ9lWOICN3s7YRkTkr6CV0OvLrRsl!V8HnmVAbjmXMjoIlq8RWMxtA3EBT2CqhMqXBK80KAUIwHR1YUQtr81MX6OL6L4cMzKHprZBtnBQw!N1pvBtin0DCIpxK8wx5/c6ZhFWjfzK/1cpZwSeO87mQ= X-Complaints-To: abuse@iinet.com X-DMCA-Complaints-To: abuse@iinet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2388 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10788 On 12/15/11 9:48 PM, Knute Johnson wrote: > Using Java 7, given the class file: > > import javax.swing.*; > > public class KList extends JList { > [...] > Klist.java:7: warning: [unchecked] unchecked call to > setModel(ListModel) as a > member of the raw type JList > setModel(model); > ^ > where E is a type-variable: > E extends Object declared in class JList > 1 warning > > How do you extend this class with generic types? I haven't been keeping up with the v7 stuff. I take it that in that version, JList is now generic? If so, then you need to decide whether KList will also be generic, or simply inherit some concrete version of JList. Generic: public class KList extends JList { ListModel model = new DefaultListModel(); public KList() { setModel(model); } } Concrete: // "int" is just for example…could be anything public class KList extends JList { ListModel model = new DefaultListModel(); public KList() { setModel(model); } } Either of those ought to work. Pete