public FPGACommanderListWindow( String Title, Color fg, boolean count, FPGACommanderListModel model) { super((count) ? Title + " (0)" : Title); this.Title = Title; setResizable(true); setAlwaysOnTop(false); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); Color bg = Color.black; textArea.setBackground(bg); textArea.setForeground(fg); textArea.setSelectionBackground(fg); textArea.setSelectionForeground(bg); textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize)); textArea.setModel(model); textArea.setCellRenderer(model.getMyRenderer(count)); textArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); model.addListDataListener(this); JScrollPane textMessages = new JScrollPane(textArea); textMessages.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); textMessages.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(textMessages); setLocationRelativeTo(null); textArea.addKeyListener(this); pack(); addWindowListener(this); this.count = count; this.model = model; }
@Override public void contentsChanged(ListDataEvent e) { setTitle((count) ? Title + " (" + model.getCountNr() + ")" : Title); }