Application Techniques



Using the JTextField Control

How to use the Swing text field 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 and setting a string value for a text field   Top of page

The following code uses getText() to get the text from fldTextFrom and setText() to place the text in the field fldTextTo.

This code is from the actionPerformed event of btnSetText.

  // Get the value of the Text From field and use this to set 
  // the value of the Text To field 
  fldTextTo.setText(fldTextFrom.getText()); 

Notes about the code

Getting and setting an integer value for a text field   Top of page

The following code uses getValue() to get the text from the text field fldIntegerFrom and setValue() to place the text in fldIntegerTo.

This code is from the actionPerformed event of btnSetInteger.

  // Get the value of the Integer From field and use this to set  
  // the value of the Integer To field 
  fldIntegerTo.setValue(fldIntegerFrom.getValue()); 

Notes about the Code

Getting and setting a date value for a text field   Top of page

The following code uses getValue() to get the text from the text field fldDateFrom and setValue() to place the text in fldDateTo.

This code is from the actionPerformed event of btnSetDate.

  // Get the value of the Date From field and use this to set  
  // the value of the Date To field 
  fldDateTo.setValue(fldDateFrom.getValue()); 





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