该类Controller
是一个单例,这似乎是一种允许安全传递this
到Controller
.
Netbeans 给
配置“在构造函数中传递可疑参数”提示
这让controller.addObserver(this);
我问更好的技术是什么,尽管我认为这不是一个好方法。
package net.bounceme.dur.usenet.swing;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.mail.Folder;
import javax.swing.ListModel;
import net.bounceme.dur.usenet.controller.Controller;
import net.bounceme.dur.usenet.controller.MessageBean;
import net.bounceme.dur.usenet.controller.MessagesDefaultListModel;
public class MessageSelect extends javax.swing.JPanel implements Observer {
private static final Logger LOG = Logger.getLogger(MessageSelect.class.getName());
private Controller controller = Controller.getInstance();
private ListModel messages = new MessagesDefaultListModel();
private MessageBean messageBean = new MessageBean();
@SuppressWarnings("unchecked")
public MessageSelect() {
controller.addObserver(this);
initComponents();
messagesJList.setPrototypeCellValue("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}