... displayMessage(final String messageToDisplay)
163    {
164       SwingUtilities.invokeLater(
165          new Runnable()
166          {
167             public void run() // updates displayArea
168             {
169                displayArea.append(messageToDisplay);
170             }
171          }
172       );
173    }
174
175    // manipulates enterField in the event-dispatch thread
176    private void setTextFieldEditable(final boolean editable)
177    {
178       SwingUtilities.invokeLater(
179          new Runnable()
180          {
181             public void run() // sets enterField's editability
182             {
183                enterField.setEditable(editable);
184             }
185          }
186         );
187     }
188  }

Fig. 28.6 Class that tests the Client.


 1   // Fig. 28.6: ClientTest.java
 2   // Class that tests the Client.
 3   import javax.swing.JFrame;
 4
 5   public class ClientTest
 6   {
 7      public static void main(String[] args) ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.