1 |
/* JList.java -- |
/* JList.java -- |
2 |
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. |
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
129 |
*/ |
*/ |
130 |
public static final int HORIZONTAL_WRAP = 2; |
public static final int HORIZONTAL_WRAP = 2; |
131 |
|
|
|
/** Fired in a PropertyChangeEvent when the "cellRenderer" property changes. */ |
|
|
public static final String CELL_RENDERER_PROPERTY_CHANGED = "cellRenderer"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "fixedCellHeight" property changes. */ |
|
|
public static final String FIXED_CELL_HEIGHT_PROPERTY_CHANGED = "fixedCellHeight"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "fixedCellWidth" property changes. */ |
|
|
public static final String FIXED_CELL_WIDTH_PROPERTY_CHANGED = "fixedCellWidth"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "layoutOrientation" property changes. */ |
|
|
public static final String LAYOUT_ORIENTATION_PROPERTY_CHANGED = "layoutOrientation"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "model" property changes. */ |
|
|
public static final String MODEL_PROPERTY_CHANGED = "model"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "prototypeCellValue" property changes. */ |
|
|
public static final String PROTOTYPE_CELL_VALUE_PROPERTY_CHANGED = "prototypeCellValue"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "selectionBackground" property changes. */ |
|
|
public static final String SELECTION_BACKGROUND_PROPERTY_CHANGED = "selectionBackground"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "selectionForeground" property changes. */ |
|
|
public static final String SELECTION_FOREGROUND_PROPERTY_CHANGED = "selectionForeground"; |
|
|
|
|
|
/** Fired in a PropertyChangeEvent when the "selectionModel" property changes. */ |
|
|
public static final String SELECTION_MODEL_PROPERTY_CHANGED = "selectionModel"; |
|
|
|
|
|
|
|
132 |
/** |
/** |
133 |
* This property indicates whether "drag and drop" functions are enabled |
* This property indicates whether "drag and drop" functions are enabled |
134 |
* on the list. |
* on the list. |
159 |
* is one of the integer constants {@link #VERTICAL}, {@link |
* is one of the integer constants {@link #VERTICAL}, {@link |
160 |
* #VERTICAL_WRAP}, or {@link #HORIZONTAL_WRAP}. |
* #VERTICAL_WRAP}, or {@link #HORIZONTAL_WRAP}. |
161 |
*/ |
*/ |
|
|
|
162 |
int layoutOrientation; |
int layoutOrientation; |
163 |
|
|
164 |
/** This property holds the data elements displayed by the list. */ |
/** This property holds the data elements displayed by the list. */ |
377 |
*/ |
*/ |
378 |
public void setFixedCellHeight(int h) |
public void setFixedCellHeight(int h) |
379 |
{ |
{ |
380 |
|
if (fixedCellHeight == h) |
381 |
|
return; |
382 |
|
|
383 |
int old = fixedCellHeight; |
int old = fixedCellHeight; |
384 |
fixedCellHeight = h; |
fixedCellHeight = h; |
385 |
firePropertyChange(FIXED_CELL_WIDTH_PROPERTY_CHANGED, old, h); |
firePropertyChange("fixedCellWidth", old, h); |
386 |
} |
} |
387 |
|
|
388 |
|
|
409 |
* #prototypeCellValue} property is set, but setting it explicitly |
* #prototypeCellValue} property is set, but setting it explicitly |
410 |
* overrides the width computed from {@link #prototypeCellValue}. |
* overrides the width computed from {@link #prototypeCellValue}. |
411 |
* |
* |
412 |
* @see #getFixedCellWidth |
* @see #getFixedCellHeight |
413 |
* @see #getPrototypeCellValue |
* @see #getPrototypeCellValue |
414 |
*/ |
*/ |
415 |
public void setFixedCellWidth(int h) |
public void setFixedCellWidth(int w) |
416 |
{ |
{ |
417 |
int old = fixedCellHeight; |
if (fixedCellWidth == w) |
418 |
fixedCellHeight = h; |
return; |
419 |
firePropertyChange(FIXED_CELL_HEIGHT_PROPERTY_CHANGED, old, h); |
|
420 |
|
int old = fixedCellWidth; |
421 |
|
fixedCellWidth = w; |
422 |
|
firePropertyChange("fixedCellWidth", old, w); |
423 |
} |
} |
424 |
|
|
|
|
|
425 |
/** |
/** |
426 |
* Gets the value of the {@link #visibleRowCount} property. |
* Gets the value of the {@link #visibleRowCount} property. |
427 |
* |
* |
711 |
*/ |
*/ |
712 |
public void setSelectionBackground(Color c) |
public void setSelectionBackground(Color c) |
713 |
{ |
{ |
714 |
|
if (selectionBackground == c) |
715 |
|
return; |
716 |
|
|
717 |
Color old = selectionBackground; |
Color old = selectionBackground; |
718 |
selectionBackground = c; |
selectionBackground = c; |
719 |
firePropertyChange(SELECTION_BACKGROUND_PROPERTY_CHANGED, old, c); |
firePropertyChange("selectionBackground", old, c); |
720 |
repaint(); |
repaint(); |
721 |
} |
} |
722 |
|
|
737 |
*/ |
*/ |
738 |
public void setSelectionForeground(Color c) |
public void setSelectionForeground(Color c) |
739 |
{ |
{ |
740 |
|
if (selectionForeground == c) |
741 |
|
return; |
742 |
|
|
743 |
Color old = selectionForeground; |
Color old = selectionForeground; |
744 |
selectionForeground = c; |
selectionForeground = c; |
745 |
firePropertyChange(SELECTION_FOREGROUND_PROPERTY_CHANGED, old, c); |
firePropertyChange("selectionForeground", old, c); |
746 |
} |
} |
747 |
|
|
748 |
/** |
/** |
853 |
|
|
854 |
ListCellRenderer old = cellRenderer; |
ListCellRenderer old = cellRenderer; |
855 |
cellRenderer = renderer; |
cellRenderer = renderer; |
856 |
firePropertyChange(CELL_RENDERER_PROPERTY_CHANGED, old, renderer); |
firePropertyChange("cellRenderer", old, renderer); |
857 |
revalidate(); |
revalidate(); |
858 |
repaint(); |
repaint(); |
859 |
} |
} |
889 |
if (this.model != null) |
if (this.model != null) |
890 |
this.model.addListDataListener(listListener); |
this.model.addListDataListener(listListener); |
891 |
|
|
892 |
firePropertyChange(MODEL_PROPERTY_CHANGED, old, model); |
firePropertyChange("model", old, model); |
893 |
revalidate(); |
revalidate(); |
894 |
repaint(); |
repaint(); |
895 |
} |
} |
921 |
if (selectionModel != null) |
if (selectionModel != null) |
922 |
selectionModel.addListSelectionListener(listListener); |
selectionModel.addListSelectionListener(listListener); |
923 |
|
|
924 |
firePropertyChange(SELECTION_MODEL_PROPERTY_CHANGED, old, model); |
firePropertyChange("selectionModel", old, model); |
925 |
revalidate(); |
revalidate(); |
926 |
repaint(); |
repaint(); |
927 |
} |
} |
1001 |
*/ |
*/ |
1002 |
public void setPrototypeCellValue(Object obj) |
public void setPrototypeCellValue(Object obj) |
1003 |
{ |
{ |
1004 |
|
if (prototypeCellValue == obj) |
1005 |
|
return; |
1006 |
|
|
1007 |
Object old = prototypeCellValue; |
Object old = prototypeCellValue; |
1008 |
Component comp = getCellRenderer() |
Component comp = getCellRenderer() |
1009 |
.getListCellRendererComponent(this, obj, 0, false, false); |
.getListCellRendererComponent(this, obj, 0, false, false); |
1011 |
fixedCellWidth = d.width; |
fixedCellWidth = d.width; |
1012 |
fixedCellHeight = d.height; |
fixedCellHeight = d.height; |
1013 |
prototypeCellValue = obj; |
prototypeCellValue = obj; |
1014 |
firePropertyChange(PROTOTYPE_CELL_VALUE_PROPERTY_CHANGED, old, obj); |
firePropertyChange("prototypeCellValue", old, obj); |
1015 |
} |
} |
1016 |
|
|
1017 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |