Jframe buttondemo checkboxdemo radiobuttondemo

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: dd a text field to the preceding example to let the user set a new message. JFrame ButtonDemo CheckBoxDemo RadioButtonDemo TextFieldDemo TextFieldDemo Run EE3206/EE5805 Java Programming & Applications 24 JTextArea If you want to let the user enter multiple lines of text, you cannot use text fields unless you create several of them. The solution is to use JTextArea, which enables the user to enter multiple lines of text. JTextArea javax.swing.text.JTextComponent javax.swing.JTextArea -columns: int -rows: int -tabSize: int -lineWrap: boolean -wrapStyleWord: boolean +JTextArea() +JTextArea(rows: int, columns: int) +JTextArea(text: String) The number of columns in this text area. The number of rows in this text area. The number of characters used to expand tabs (default: 8). Indicates whether the line in the text area is automatically wrapped (default: false). Indicates whether the line is wrapped on words or characters (default: false). Creates a default empty text area. Creates an empty text area with the specified number of rows and columns. Creates a new text area with the specified text displayed. The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. +JTextArea(text: String, rows: int, columns: int) Creates a new text area with the specified text and number of rows and columns. Appends the string to text in the text area. +append(s: String): void +insert(s: String, pos: int): void +replaceRange(s: String, start: int, end: int): void +getLineCount(): int Inserts string s in the specified position in the text area. Replaces partial text in the range from position start to end with string s. Returns the actual number of lines contained in the text area. EE3206/EE5805 Java Programming & Applications 25 JTextArea Constructors & Properties JTextArea(int rows, int columns) JTextArea(int Creates a text area with the specified number of rows and columns. JTextArea(String s, int rows, int columns) JTextArea(String Creates a text area with the initial text and the number of rows and columns specified. text text editable editable columns columns lineWrap lineWrap wrapStyleWord wrapStyleWord rows rows lineCount lineCount tabSize tabSize EE3206/EE5805 Java Programming & Applications 26 Example: Using Text Areas This example gives a program that displays an image in a label, This a title in a label, and a text in a text area. TextAreaDemo Run JPanel JFrame DescriptionPanel -jlblImage: JLabel -jtaTextDescription: JTextArea +setImageIcon(icon: ImageIcon): void +setTitle(title: String): void +setTextDescription(text: String): void +getMinimumSize(): Dimension 1 1 TextAreaDemo EE3206/EE5805 Java Programming & Applications 27 JComboB...
View Full Document

This note was uploaded on 01/11/2011 for the course EE 3206 taught by Professor Cwting during the Spring '07 term at City University of Hong Kong.

Ask a homework question - tutors are online