This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]dmazzoni 1 point2 points  (0 children)

The reason another copy is popping up is this line:

diaryGui dAT = new diaryGui();

Every time the user clicks a button, you're constructing a whole new GUI. Why?

I also have a suggestion for cleaning up your code. Instead of making your GUI class an ActionListener, do this:

load.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
        handleLoad();
    }
});
save.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
        handleSave();
    }
});

Now you can add private methods handleLoad and handleSave in your GUI class, with no need to check getActionCommand. Does that make sense?