0

hi
this is jus a question. if you are doing a program that uses a GUI, with the radiobutton, checkboxes and so on
why do you have add an import for all the jradiobutton and jcheckbox. is is necessary to add an import for each of them

2
Contributors
5
Replies
18
Views
6 Months
Discussion Span
Last Post by JamesCherrill
0

import is optional.
You can always code the fully-qualified name javax.swing.JRadioButton every time you need it, but that can be very tedious.
So you have the option to import javax.swing.JRadioButton at the start of your .java file and then you can just use the short name JRadioButton
Similarly you can import the names of every swing class with import javax.swing.*
(but be careful - for example if you import java.awt.* then List can be seen as the awt control, not the Collection).

The choice is yours for each .java file ... use the fully qualified name, or use inport .

Edited by JamesCherrill

0

... more precisely:

its the same answer for any class in any package other than the current package.
Except there is an implicit import for java.lang.* so you can refer to classes like String without having to do anything.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.