I have written an application that is using Swing for the GUI, accepts a file via the GUI, parses the Input, saves it in DataList and sends it to a server. I'm concerned about the whole design of my program, which I don't think is very good. I'm using Netbeans to design the GUI and have a class MainClass that starts that GUI and has a static reference to the GUI. Also there are a couple of ExecClasses that do the aforementioned parsing and sending of the data.
+----------------------+
| MainClass (static) |
|----------------------|
+------+ -DataList +-----+
| | | |
static| +-+--------------+-----+ |static
reference | | |reference
| |new () | new () |
| | | |
| | | |
+-+--------v----+ +--v-----------+--+
| | | |
| SwingGUIClass | | ExecClasses |
| | | |
+--/\-----------+ +-----------------+
|
Input file
Here a short overview of the MainClass :
public class MainClass {
private static MainClass mainClass;
private static ExecClass1 ex1;
private static ExecClass2 ex2;
private static ExecClass3 ex3;
public static void startExecClass2(String param){
ex2 = new ExecClass2(param);
}
I'm using these references so that the SwingGUIClass can execute a method in the ExecClass1 for example. I chose this approach since I have a TextArea that needs to get the data out of one of the ExecClasses and display it in the GUI. Since I can't modify the TextArea from the ExecClass.
public class SwingGUIClass {
[...]
private void ButtonActionPerformed(java.awt.event.ActionEvent evt) {
Label.setText(MainClass.getList());
}
private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {
MainClass.startExecClass2(Button2.getText());
}
I understand that this is a far from great design and not following a couple of good practice guides, e.g. MVC. So my question is : How would you design this and which general pointers can you give me?