Skip to main content

Selectable Input Components

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

Abstract

So far, you have learned how to use simple buttons and a variety of text input fields. In this chapter, you’ll take a look at using some other input components, ones that can be selected. All of the components in this chapter have two possible states, they are either selected or not. I’ll start by describing toggle buttons, proceed to check boxes, and then to radio buttons. I will also discuss how to group these fields in order to make interesting user presentations.

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/JToggleButton.html .

  2. 2.

    See http://docs.oracle.com/javase/8/docs/api/java/awt/event/ItemListener.html .

  3. 3.

    See http://docs.oracle.com/javase/8/docs/api/java/awt/event/ActionListener.html .

  4. 4.

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

  5. 5.

    Initially, I had the code to create and add each JCheckBox to the frame on a single line. Width limitations for these listings, however, meant that it would be best, at least for this example, to create and use the addCB() method in lines 9-15 instead.

  6. 6.

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

  7. 7.

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

  8. 8.

    Unless, of course, you have something like an event handler deselect everything in the group.

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). Selectable Input Components. In: Swing for Jython. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0817-5_8

Download citation

Publish with us

Policies and ethics