Click to See Complete Forum and Search --> : textfield editing


The One
02-21-2006, 02:38 PM
is it possible so that i cant edit a textfield. no number can be typed in in but wen a calculation is performed it puts the answer in that textfield and cant be edited jus by typin in it?? How?

davey
02-21-2006, 09:48 PM
I believe if you make a jtextfield and then disable it you will still be able to control it within the program to change the value

The One
02-22-2006, 07:37 AM
ok.. so how is that done...??

davey
02-22-2006, 08:34 AM
import javax.swing.*;
^ above class

v in program
JTextField fubar = new JTextField();

v makes uneditable to user
fubar.setEnabled(false);

v sets fubar to string
fubar.setText("STRING");

try fiddling with that and see what you come up with

The One
02-22-2006, 12:40 PM
ok thanks. iv now created a JTextArea. iv typed something to be printed in the GUI. but it can be edited. how do i make it un editable. the above doesnt work for JTextArea??