Concept explainers
Make text field read-only:
The method that is used to make the text field readable is “setEditable”.
Hence, the correct answer is option “D”.
Explanation of Solution
Read-only text field:
- The text that can be changed only with the application code is called as read-only text field.
- The read-only text field will not allow the user to edit its contents.
- The usage of the “JTextField” component is made in a different way such that the text field cannot be edited by the user instead can be modified using the code of the application and it is made through the method “setEditable”
Format of defining the “setEditable” method:
The below is the general format for defining the “setEditable” method:
setEditable(boolean editable)
Example:
The below is the usage of the method “setEditable” for the text field that is generated:
//create a new text field
JTextField Total=new JTextField(10);
//set the text field read only
Total.setEditable(false);
Hence, the method that is used to make the text field readable is “setEditable”.
Reason for the incorrect answers:
setReadOnly:
There is no method defined “setReadOnly”.
Hence, the option “A” is wrong.
setChangeable:
There is no method defined “setChangeable”.
Hence, the option “B” is wrong.
setUneditable:
There is no method defined “setUneditable”.
Hence, the option “C” is wrong.
Want to see more full solutions like this?
Chapter 13 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education