[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug swing/27222] New: JList incompadibilities
From: |
subanark at gmail dot com |
Subject: |
[Bug swing/27222] New: JList incompadibilities |
Date: |
20 Apr 2006 03:33:37 -0000 |
Moderate: Subclasses that use custom ListModels and guard aganinst other
ListModels by overriding setListModel will fail since Classpath's sets a
default list model even in the constructor that takes a ListModel argument.
Moderate: Classpath does not support null UI. Methods need to check if the UI
is null before quering it.
Minor: Some method calls differ durring construction that can cause
incompadibilites when overriden (but not for most sane systems).
import java.awt.Rectangle;
import javax.swing.AbstractListModel;
import javax.swing.JList;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
public class JListTest extends JList{
public static class MyListModel extends AbstractListModel {
public int getSize() {
return 0;
}
public Object getElementAt(int index) {
throw new IndexOutOfBoundsException();
}
}
public JListTest(MyListModel model)
{
super(model);
setUI(null);
}
@Override
public void setModel(ListModel model) {
//Other code might use instanceof on model to insure it is the
right kind.
System.out.println("setModel -- Bad");
super.setModel(model);
}
@Override
public void setOpaque(boolean isOpaque) {
System.out.println("setOpaque -- Good");
super.setOpaque(isOpaque);
}
@Override
public void setSelectionMode(int selectionMode) {
System.out.println("setSelectionModel -- Bad");
super.setSelectionMode(selectionMode);
}
@Override
public void setSelectionModel(ListSelectionModel selectionModel) {
System.out.println("setSelectionModel -- Bad");
super.setSelectionModel(selectionModel);
}
@Override
public Rectangle getCellBounds(int index0, int index1) {
System.out.println("getCellBounds called");
try
{
return super.getCellBounds(index0, index1);
}
catch(NullPointerException e)
{
System.out.println("getCellBounds threw NPE");
return null;
}
}
public static void main(String[] args) {
JList list = new JListTest(new MyListModel());
//null UI test
list.getCellBounds(0,0);
}
}
--
Summary: JList incompadibilities
Product: classpath
Version: 0.90
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: swing
AssignedTo: roman at kennke dot org
ReportedBy: subanark at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27222
- [Bug swing/27222] New: JList incompadibilities,
subanark at gmail dot com <=