Application Techniques



Using the JList Control

How to use the JList Swing control on a form.

About this technique

Details

Category

Java Client Techniques> Version 3 Swing-based controls

Description

You'll learn about:

You can run this technique code from:

NOTE   First make sure that database is running on your localhost SilverStream Server

Related reading

See the chapter on the Form Designer in the Tools Guide

Getting the string and int values of a selected row   Top of page

The following code uses the getItemAt() and getSelectedIndex() methods to get the String value of a selected row in the JList listEmployees, then uses setText() to display it in the text field fldRowText. Then the code uses getValue() to get the row index value as a String and displays in fldRowValue.

This code is from the actionPerformed event of listEmplolyees:

  // Get the display text value of the selected row and display  
  // this in fldRowText 
  fldRowText.setText((String)  
    listEmployees.getItemAt(listEmployees.getSelectedIndex()). 
      toString()); 
   
  // Get the value and display it in fldRowValue 
  fldRowValue.setText(((Integer) 
    listEmployees.getValue()).toString()); 





Copyright © 2000, SilverStream Software, Inc. All rights reserved.