JDialog input board

I need advice on JDialog.

I need to catch the “input” data, and I wonder what is the best way to do this. Well, here is the complete problem. When the user clicks the button (located on the JFrame), JDialog appears, and there are 3 text fields for entries and one combo box. After the user clicks ok, I need to return this data to the JFrame. Well, I can do it in my way, but this is too much spaghetti code :)) Which listener should I use? And if you are ready to give me some sample code, I would be grateful :)

+3
source share
1 answer

Hmm, there are many ways to solve it, maybe you can try the delegate approach with an interface similar to the following:

public interface DialogListener {
    public boolean okClicked(String input1, String input2, String input3, String combo);
    public void cancelClicked();
}

( - ).

, MVC .

, .

, .

, , :

public interface DialogListener {
    public boolean okClicked(JDialog dialog, Map<String, JComponent> components);
    public void cancelClicked();
}
+1

All Articles