Tasks studies - laboratory
public class JComboBox extends JComponent implements ItemSelectable, ListDataListener, ActionListener, Accessible
Commonly used Constructors:
Constructor | Description |
---|---|
JComboBox() |
Creates a JComboBox with a default data model. |
JComboBox(Object[] items) |
Creates a JComboBox that contains the elements in the specified array. |
JComboBox(Vector<?> items) |
Creates a JComboBox that contains the elements in the specified Vector. |
Commonly used methods:
Methods | Description |
---|---|
void addItem(Object anObject) |
It is used to add an item to the item list. |
void removeItem(Object anObject) |
It is used to delete an item to the item list. |
void removeAllItems() |
It is used to remove all the items from the list. |
void setEditable(boolean b) |
It is used to determine whether the JComboBox is editable. |
void addActionListener(ActionListener a) |
It is used to add the ActionListener. |
Implant the applications as per the view below.
After selecting the appropriate language from the drop-down list, the text will appear in the label, after pressing the Show button, a massage will appear with information about the selected language.
Commonly used Constructors:
Constructor | Description |
---|---|
JTable() |
Creates a table with empty cells. |
JTable(Object[][] rows, Object[] columns) |
Creates a table with the specified data. |
Design an application based on the view provided below.
```public class JList extends JComponent implements Scrollable, Accessible
```
Commonly used Constructors:
Constructor | Description |
---|---|
JList() |
Creates a JList with an empty, read-only, model. |
JList(array[] listData) |
Creates a JList that displays the elements in the specified array. |
JList(ListModel<array> dataModel) |
Creates a JList that displays elements from the specified, non-null, model. |
Commonly used methods:
Constructor | Description | |||
---|---|---|---|---|
void addListSelectionListener(ListSelectionListener listener) |
It is used to add a listener to the list, to be notified each time a change to the selection occurs. | |||
int getSelectedIndex() |
It is used to return the smallest selected cell index. | |||
ListModel getModel() |
It is used to return the data model that holds a list of items displayed by the JList component. | void setListData(Object[] listData) |
It is used to create a read-only ListModel from an array of objects. |
Implement applications according to the view below.
Tasks to solve independently
You should propose a GUI application, which an example of the appearance is shown below, the application should have the following functionalities:
• After turning on the application, the Save Existing button is inactive
• After selecting a person from the list, the necessary information appears in the appropriate fields and instead of text 0 yers information about the age of the person appears.
• The user can enter new people by entering data according to requirements and clicking Save New.
• Save Existing allows you to save modified data of a given user.