Sunday, October 31, 2021

JList Populated From String Array


import javax.swing.JFrame;
import javax.swing.JList;

public class ListTest {

public ListTest() {
JFrame frame = new JFrame();
frame.setTitle("JList Test");
frame.setSize(640,480);
frame.setLocationRelativeTo(null);

String[] items = {"One", "Two", "Three"};
JList list = new JList(items);

frame.add(list);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public static void main(String[] args) {
new ListTest();
}
}

No comments:

Post a Comment

We Live In A Simulation

 You read that title right. We live in a simulation. Nothing is real. It's as real as you want it to be. But that doesn't mean it...