Jframe buttondemo checkboxdemo radiobuttondemo

Info icon This 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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern