237 * public void mouseClicked(MouseEvent e) {
238 * if (e.getClickCount() == 2) {
239 * int index = list.locationToIndex(e.getPoint());
240 * System.out.println("Double clicked on Item " + index);
241 * }
242 * }
243 * };
244 * list.addMouseListener(mouseListener);
245 * </pre>
246 * <p>
247 * <strong>Warning:</strong> Swing is not thread safe. For more
248 * information see <a
249 * href="package-summary.html#threading">Swing's Threading
250 * Policy</a>.
251 * <p>
252 * <strong>Warning:</strong>
253 * Serialized objects of this class will not be compatible with
254 * future Swing releases. The current serialization support is
255 * appropriate for short term storage or RMI between applications running
256 * the same version of Swing. As of 1.4, support for long term storage
257 * of all JavaBeans™
258 * has been added to the <code>java.beans</code> package.
259 * Please see {@link java.beans.XMLEncoder}.
260 * <p>
261 * See <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/list.html">How to Use Lists</a>
262 * in <a href="https://docs.oracle.com/javase/tutorial/"><em>The Java Tutorial</em></a>
263 * for further documentation.
264 *
265 * @see ListModel
266 * @see AbstractListModel
267 * @see DefaultListModel
268 * @see ListSelectionModel
269 * @see DefaultListSelectionModel
270 * @see ListCellRenderer
271 * @see DefaultListCellRenderer
272 *
273 * @param <E> the type of the elements of this list
274 *
275 * @author Hans Muller
276 * @since 1.2
277 */
2866 */
2867 @BeanProperty(bound = false)
2868 public AccessibleContext getAccessibleContext() {
2869 if (accessibleContext == null) {
2870 accessibleContext = new AccessibleJList();
2871 }
2872 return accessibleContext;
2873 }
2874
2875 /**
2876 * This class implements accessibility support for the
2877 * {@code JList} class. It provides an implementation of the
2878 * Java Accessibility API appropriate to list user-interface
2879 * elements.
2880 * <p>
2881 * <strong>Warning:</strong>
2882 * Serialized objects of this class will not be compatible with
2883 * future Swing releases. The current serialization support is
2884 * appropriate for short term storage or RMI between applications running
2885 * the same version of Swing. As of 1.4, support for long term storage
2886 * of all JavaBeans™
2887 * has been added to the <code>java.beans</code> package.
2888 * Please see {@link java.beans.XMLEncoder}.
2889 */
2890 @SuppressWarnings("serial") // Same-version serialization only
2891 protected class AccessibleJList extends AccessibleJComponent
2892 implements AccessibleSelection, PropertyChangeListener,
2893 ListSelectionListener, ListDataListener {
2894
2895 int leadSelectionIndex;
2896
2897 /**
2898 * Constructs an {@code AccessibleJList}.
2899 */
2900 public AccessibleJList() {
2901 super();
2902 JList.this.addPropertyChangeListener(this);
2903 JList.this.getSelectionModel().addListSelectionListener(this);
2904 JList.this.getModel().addListDataListener(this);
2905 leadSelectionIndex = JList.this.getLeadSelectionIndex();
2906 }
|
237 * public void mouseClicked(MouseEvent e) {
238 * if (e.getClickCount() == 2) {
239 * int index = list.locationToIndex(e.getPoint());
240 * System.out.println("Double clicked on Item " + index);
241 * }
242 * }
243 * };
244 * list.addMouseListener(mouseListener);
245 * </pre>
246 * <p>
247 * <strong>Warning:</strong> Swing is not thread safe. For more
248 * information see <a
249 * href="package-summary.html#threading">Swing's Threading
250 * Policy</a>.
251 * <p>
252 * <strong>Warning:</strong>
253 * Serialized objects of this class will not be compatible with
254 * future Swing releases. The current serialization support is
255 * appropriate for short term storage or RMI between applications running
256 * the same version of Swing. As of 1.4, support for long term storage
257 * of all JavaBeans
258 * has been added to the <code>java.beans</code> package.
259 * Please see {@link java.beans.XMLEncoder}.
260 * <p>
261 * See <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/list.html">How to Use Lists</a>
262 * in <a href="https://docs.oracle.com/javase/tutorial/"><em>The Java Tutorial</em></a>
263 * for further documentation.
264 *
265 * @see ListModel
266 * @see AbstractListModel
267 * @see DefaultListModel
268 * @see ListSelectionModel
269 * @see DefaultListSelectionModel
270 * @see ListCellRenderer
271 * @see DefaultListCellRenderer
272 *
273 * @param <E> the type of the elements of this list
274 *
275 * @author Hans Muller
276 * @since 1.2
277 */
2866 */
2867 @BeanProperty(bound = false)
2868 public AccessibleContext getAccessibleContext() {
2869 if (accessibleContext == null) {
2870 accessibleContext = new AccessibleJList();
2871 }
2872 return accessibleContext;
2873 }
2874
2875 /**
2876 * This class implements accessibility support for the
2877 * {@code JList} class. It provides an implementation of the
2878 * Java Accessibility API appropriate to list user-interface
2879 * elements.
2880 * <p>
2881 * <strong>Warning:</strong>
2882 * Serialized objects of this class will not be compatible with
2883 * future Swing releases. The current serialization support is
2884 * appropriate for short term storage or RMI between applications running
2885 * the same version of Swing. As of 1.4, support for long term storage
2886 * of all JavaBeans
2887 * has been added to the <code>java.beans</code> package.
2888 * Please see {@link java.beans.XMLEncoder}.
2889 */
2890 @SuppressWarnings("serial") // Same-version serialization only
2891 protected class AccessibleJList extends AccessibleJComponent
2892 implements AccessibleSelection, PropertyChangeListener,
2893 ListSelectionListener, ListDataListener {
2894
2895 int leadSelectionIndex;
2896
2897 /**
2898 * Constructs an {@code AccessibleJList}.
2899 */
2900 public AccessibleJList() {
2901 super();
2902 JList.this.addPropertyChangeListener(this);
2903 JList.this.getSelectionModel().addListSelectionListener(this);
2904 JList.this.getModel().addListDataListener(this);
2905 leadSelectionIndex = JList.this.getLeadSelectionIndex();
2906 }
|