import [Link].
*;
import [Link].*;
import [Link];
import [Link];
import [Link].*;
public class ToDoListApp {
private JFrame frame;
private JTextField taskField;
private JList<String> taskList;
private DefaultListModel<String> listModel;
public ToDoListApp() {
frame = new JFrame("To-Do List App");
taskField = new JTextField(20);
JButton addButton = new JButton("Add Task");
JButton removeButton = new JButton("Remove Task");
listModel = new DefaultListModel();
taskList = new JList(listModel);
JScrollPane listScrollPane = new JScrollPane(taskList);
// Layout setup
JPanel panel = new JPanel();
[Link](new BorderLayout());
[Link](taskField, [Link]);
[Link](listScrollPane, [Link]);
JPanel buttonPanel = new JPanel();
[Link](addButton);
[Link](removeButton);
[Link](buttonPanel, [Link]);
// Add action listeners
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String task = [Link]().trim();
if (![Link]()) {
[Link](task);
[Link]("");
} else {
[Link](frame, "Please enter a task.");
});
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int selectedIndex = [Link]();
if (selectedIndex != -1) {
[Link](selectedIndex);
} else {
[Link](frame, "Please select a task to remove.");
});
// Final setup
[Link](JFrame.EXIT_ON_CLOSE);
[Link](panel);
[Link](400, 300);
[Link](true);
[Link](null); // Center the window
public static void main(String[] args) {
[Link](ToDoListApp:new);
OUTPUT: