• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Textareas

 How do i prevent users from changing the contents of the
  textarea displayed on the applet? How do i make it a read
  only display?
0
kans
Asked:
kans
1 Solution
 
kansAuthor Commented:
Edited text of question
0
 
bernfarrCommented:
From the Java Class Library book. Excuse any typos. The call you want is the setEditable() one below.

import java.awt.*;
class Main extends Frame {
TextArea ta = new TextArea();
Checkbox cb = new Checkbox("Editable", null, true );

Main() {
super( "setEditable example" );
add( "Center", ta );
add( "South", cb );
pack();
show();
}

public boolean action(Event evt, Object ob ){
  if ( evt.target == cb ) {
    ta.setEditable( cb.getState() );
  }
  return true;
}

static public void main(String[] args) {
  new Main();
}
}

0
 
sailwindCommented:
Simply invoke the textArea's setEditable method to be false.

TextField mytext = new TextField();
mytext.setEditable(false);

0
 
pureDanCommented:
If U want to prevent someone to change your TextArea context
use SetEditable(false) method, this way.
-----
//your previously defined TextArea
TextArea ta=new TextArea();
ta.setEditable(false);
------
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now