Skip to main content

Other Input Components

  • Chapter
  • First Online:
Swing for Jython
  • 891 Accesses

Abstract

This chapter presents other input components available in the Swing class hierarchy. Specifically, it deals with some specialized text input fields, such as JPassword, three types of ComboBoxes (static, editable, and dynamic), and formatted text fields. Additionally, I combine some of these while discussing the JSpinner class at the end of the chapter.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 59.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    See http://docs.oracle.com/javase/8/docs/api/javax/swing/JPasswordField.html .

  2. 2.

    Unfortunately, there are lots of ways for script writers to overlook good security practices, so be careful.

  3. 3.

    It is interesting to note that even though the password text is visible, you still can’t copy its value to the system’s clipboard.

  4. 4.

    See http://www.jython.org/javadoc/org/python/modules/jarray.html .

  5. 5.

    Table 7-2 only lists the function signatures that have a typeCode argument for simplicity’s sake.

  6. 6.

    The expression (i.e., cb.getItemCount() > 1) will be true (i.e., 1) when more than one item is present on the list; this keeps the button enabled. When the list only has one item, the expression is false (i.e., 0) and the button is disabled.

  7. 7.

    See http://docs.oracle.com/javase/8/docs/api/javax/swing/JFormattedTextField.html .

  8. 8.

    See http://docs.oracle.com/javase/8/docs/api/java/text/Format.html .

  9. 9.

    Note: You’ll revisit the JFormattedTextField class in Chapter 14.

  10. 10.

    Note: The eval() function, as shown in line 15, is normally discouraged. However, using it in this example allowed the addFTF() method call to be greatly simplified and much shorter.

  11. 11.

    See http://docs.oracle.com/javase/8/docs/api/java/text/NumberFormat.html .

  12. 12.

    Line 5 is included to show how an alias for the DateFormatSymbols was defined. This allowed line 17 to be short enough to be fit easily in the available space.

  13. 13.

    See http://docs.oracle.com/javase/8/docs/api/java/text/DateFormatSymbols.html .

  14. 14.

    There are many more methods provided by the DateFormatSymbols class that aren’t covered in this book. Feel free to experiment with and use these other methods.

  15. 15.

    This is not a bug, as is explained in the bug report found here: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4146173 . It’s a feature. Personally, I kind of like the explanation that exists in various places on the web that these eight-day weeks and 13-month years were created for managers and product planners to explain and justify the development schedules. But that’s just a guess.

  16. 16.

    See http://docs.oracle.com/javase/8/docs/api/javax/swing/JSpinner.html .

  17. 17.

    See http://docs.oracle.com/javase/8/docs/api/javax/swing/SpinnerModel.html .

  18. 18.

    See http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html .

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Robert A. Gibson

About this chapter

Cite this chapter

Gibson, R.A. (2015). Other Input Components. In: Swing for Jython. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0817-5_7

Download citation

Publish with us

Policies and ethics