How do i add an action listener to a JList in a proper way?
问题 I'm trying to add an actionListener to a JList, so whenever a user click a value in the JList , it will just println the value. Here's the code public class FontProgram { public static void main(String[] args) { // TODO Auto-generated method stub JFrame mainFrame = new JFrame("Fonts Frame"); JPanel panel = new JPanel(new BorderLayout()); GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = e.getAvailableFontFamilyNames(); JComboBox fontbox = new