What have you tried?
I don't know what "newM if statement" you are referring to.
The first thing I notice is that you have a point in your code that silently swallows exceptions. Never, ever do this. At the very least, print something. In an interactive GUI application, you should inform the user there is a problem with the file.
Another thing I notice is that the logic for creating a new item doesn't
appear to save the idem anywhere - though possibly the call to setStore() is doing something funky. You seem to be creating a new stock object, and then setting the text to the second (first?) element, which may not be populated.
It is idiomatic in Swing to attach the event listeners directly to the component they are listening too. This is often done via an anonymous inner class. Doing it this way means that you don't have to determine the source of an event - it is implied.
For example:
// In the setup method:
this.OpenMI.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
try
{
this.fileLoaded = this.LoadFile();
if(fileLoaded)
{
this.printData();
this.addDataToList();
}
}
catch(IOException e)
{
// TODO: improve me!
e.printStackTrace();
}
}
});
this.newItemB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
AddItem newItem = new AddItem();
newItem.setVisible(true);
stock = new HardwareStock(40);
newItem.setStore(this);
this.HardwareDataTA.setText(stock.elementAt(1).toString());
}
});
Moving the logic performed into a separate method or class is common, otherwise the method creating these inner classes starts getting very long:
this.OpenMI.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
handleOpenMI();
}
});
this.newItemB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
handleNewItemB();
}
});