Swing has many useful classes that make graphical user interface (GUI) development easy. Some of these classes, however, are not well implemented. One example of such a class is ButtonGroup
. This article explains why ButtonGroup
is poorly designed and offers a replacement class, JButtonGroup
, which inherits from ButtonGroup
and fixes some of its problems.
Note: You can download this article’s source code from Resources.
ButtonGroup holes
Here’s a common scenario in Swing GUI development: You build a form to gather data about items that someone will enter into a database or save to a file. The form might contain text boxes, check boxes, radio buttons, and other widgets. You use the ButtonGroup
class to group all radio buttons that need single selection. When the form design is ready, you start to implement the form data. You encounter the set of radio buttons, and you need to know which button in the group was selected so you can store the appropriate information into the database or file. You’re now stuck. Why? The ButtonGroup
class does not give you a reference to the button currently selected in the group.
Find A Teacher Form:
https://docs.google.com/forms/d/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ/viewform?edit_requested=true#responses
Email:
public1989two@gmail.com
www.itsec.hk
www.itsec.vip
www.itseceu.uk
Leave a Reply