Adding in CS-115 coursework

This commit is contained in:
Frank
2025-09-27 14:53:33 -06:00
parent ad3eff2688
commit 7df7f7f319
22 changed files with 708 additions and 0 deletions

36
cs-115-test/src/List.java Normal file
View File

@@ -0,0 +1,36 @@
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class List {
public static void main(String[] args) {
JFrame frame = new JFrame();
String[] trees = { "Maple", "Larch", "Spruce", "Balsam" };
JList treeList = new JList(trees);
JPanel panel = new JPanel();
JLabel label = new JLabel("Select a Tree");
treeList.add(panel);
JButton button = new JButton("Show Me");
button.setBounds(10, 150, 230, 30);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String data = "";
if (treeList.getSelectedIndex() != -1) {
data = "Trees: " + treeList.getSelectedValue();
button.setText(data);
}
}
});
frame.add(button);
frame.add(treeList);
frame.setSize(250, 250);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}