JCheckBox renders a check-box with a label. The getPassword method gets the value entered by the user. It returns a password field of 15 column width. This is used for inserting passwords into the application.Įxample: JPasswordField pwdField = new JPasswordField(15) It renders a text-box that masks the user input text with bullet points. JPasswordField is a subclass of JTextField class. The above code renders a multi-line text-area of height 5 rows and width 20 columns, with default text initialized in the text-area. It does not restrict the number of characters that the user can input in the text-area.Įxample: JTextArea txtArea = new JTextArea("This text is default text for text area.", 5, 20) The constructor for JTextArea also expects two integer parameters which define the height and width of the text-area in columns. Similar to the JTextField, a user can input non-formatted text in the field. JTextArea class renders a multi-line text box. It renders a text box of 20 column width. It does not limit the number of characters that can be input in the box.Įxample: JTextField txtBox = new JTextField(20) This parameter sets the width of the box measured by the number of columns. To initialize the text field, call its constructor and pass an optional integer parameter to it. A user can input non-formatted text in the box. JTextField renders an editable single-line text box. This constructor returns a label with text. It does not generate any event.Įxample: JLabel textLbl = new JLabel("This is a text label.") JLabel class is used to render a read-only text label or images on the UI. It returns a button with the home icon and text Home. JButton btn2 = new JButton(homeIcon, "Home") It returns a button with a homeIcon on it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |