Solved

Textareas

Posted on 1998-09-03
4
240 Views
Last Modified: 2010-03-30
 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
Comment
Question by:kans
4 Comments
 

Author Comment

by:kans
ID: 1223506
Edited text of question
0
 
LVL 2

Accepted Solution

by:
bernfarr earned 50 total points
ID: 1223507
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
 
LVL 3

Expert Comment

by:sailwind
ID: 1223508
Simply invoke the textArea's setEditable method to be false.

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

0
 

Expert Comment

by:pureDan
ID: 1223509
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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 90
Checkbox and ListView in Android Layout 4 65
object oriented programming comparison 5 69
tomcat startup error 5 59
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question