git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
2da37d3
)
ListModel: JList constructors were bad
author
Niki Roo
<niki@nikiroo.be>
Sun, 26 Apr 2020 12:28:42 +0000
(14:28 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Sun, 26 Apr 2020 12:28:42 +0000
(14:28 +0200)
ui/ListModel.java
patch
|
blob
|
blame
|
history
diff --git
a/ui/ListModel.java
b/ui/ListModel.java
index 52fa816a55a577aa1c8b3d27e7c9132443083029..e349deef344a0bdbe33078da7c5cd7fdc19edbce 100644
(file)
--- a/
ui/ListModel.java
+++ b/
ui/ListModel.java
@@
-80,52
+80,68
@@
public class ListModel<T> extends DefaultListModel6<T> {
private int hoveredIndex;
private List<T> items = new ArrayList<T>();
private int hoveredIndex;
private List<T> items = new ArrayList<T>();
- private JList6<T> list;
private boolean keepSelection = true;
private boolean keepSelection = true;
+ @SuppressWarnings("rawtypes") // JList<?> not compatible Java 1.6
+ private JList list;
+
/**
* Create a new {@link ListModel}.
*
* @param list
/**
* Create a new {@link ListModel}.
*
* @param list
- * the {@link JList} we will handle the data of (cannot be NULL)
+ * the {@link JList
6
} we will handle the data of (cannot be NULL)
*/
*/
- @SuppressWarnings(
{ "unchecked", "rawtypes" }) //
not compatible Java 1.6
- public ListModel(JList list) {
- this((JList
6<T>
) list);
+ @SuppressWarnings(
"rawtypes") // JList<?>
not compatible Java 1.6
+ public ListModel(JList
6<T>
list) {
+ this((JList) list);
}
/**
* Create a new {@link ListModel}.
*
* @param list
}
/**
* Create a new {@link ListModel}.
*
* @param list
- * the {@link JList} we will handle the data of (cannot be NULL)
+ * the {@link JList
6
} we will handle the data of (cannot be NULL)
* @param popup
* the popup to use and keep track of (can be NULL)
*/
* @param popup
* the popup to use and keep track of (can be NULL)
*/
- @SuppressWarnings(
{ "unchecked", "rawtypes" }) //
not compatible Java 1.6
- public ListModel(final JList list, final JPopupMenu popup) {
- this((JList
6<T>
) list, popup);
+ @SuppressWarnings(
"rawtypes") // JList<?>
not compatible Java 1.6
+ public ListModel(final JList
6<T>
list, final JPopupMenu popup) {
+ this((JList) list, popup);
}
/**
* Create a new {@link ListModel}.
}
/**
* Create a new {@link ListModel}.
+ * <p>
+ * Note that you must take care of passing a {@link JList} that only handles
+ * elements of the type of this {@link ListModel} -- you can also use
+ * {@link ListModel#ListModel(JList6)} instead.
*
* @param list
*
* @param list
- * the {@link JList6} we will handle the data of (cannot be NULL)
+ * the {@link JList} we will handle the data of (cannot be NULL,
+ * must only contain elements of the type of this
+ * {@link ListModel})
*/
*/
- public ListModel(JList6<T> list) {
+ @SuppressWarnings("rawtypes") // JList<?> not compatible Java 1.6
+ public ListModel(JList list) {
this(list, null);
}
/**
* Create a new {@link ListModel}.
this(list, null);
}
/**
* Create a new {@link ListModel}.
+ * <p>
+ * Note that you must take care of passing a {@link JList} that only handles
+ * elements of the type of this {@link ListModel} -- you can also use
+ * {@link ListModel#ListModel(JList6, JPopupMenu)} instead.
*
* @param list
*
* @param list
- * the {@link JList6} we will handle the data of (cannot be NULL)
+ * the {@link JList} we will handle the data of (cannot be NULL,
+ * must only contain elements of the type of this
+ * {@link ListModel})
* @param popup
* the popup to use and keep track of (can be NULL)
*/
* @param popup
* the popup to use and keep track of (can be NULL)
*/
- public ListModel(final JList6<T> list, final JPopupMenu popup) {
+ @SuppressWarnings({ "unchecked", "rawtypes" }) // JList<?> not in Java 1.6
+ public ListModel(final JList list, final JPopupMenu popup) {
this.list = list;
list.setModel(this);
this.list = list;
list.setModel(this);
@@
-313,7
+329,7
@@
public class ListModel<T> extends DefaultListModel6<T> {
* the filter will be copied as an element (can be NULL, in that
* case all items will be copied as elements)
*/
* the filter will be copied as an element (can be NULL, in that
* case all items will be copied as elements)
*/
- @SuppressWarnings("unchecked") //
ListModel<T> and JList<T> are not j
ava 1.6
+ @SuppressWarnings("unchecked") //
JList<?> not compatible J
ava 1.6
public void filter(Predicate<T> filter) {
ListSnapshot snapshot = null;
public void filter(Predicate<T> filter) {
ListSnapshot snapshot = null;
@@
-388,7
+404,7
@@
public class ListModel<T> extends DefaultListModel6<T> {
}
}
}
}
- @SuppressWarnings("unchecked") //
ListModel<T> and JList<T> are not j
ava 1.6
+ @SuppressWarnings("unchecked") //
JList<?> not compatible J
ava 1.6
@Override
public T get(int index) {
return (T) super.get(index);
@Override
public T get(int index) {
return (T) super.get(index);