final int size1 = currentSize;
//Threading needed so that GUI and the addCode method do not freeze the users computer.
Executor executor = java.util.concurrent.Executors.newSingleThreadExecutor();
((ExecutorService) executor).submit(new Runnable() { public void run() {
final AddCode ac = new AddCode();
JFrame load = new JFrame("Loading");
JPanel container = new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
JProgressBar jpb = new JProgressBar(0,size1);
JLabel fileName = new JLabel();
load.setSize(270,70);
jpb.setValue(0);
jpb.setStringPainted(true);
load.setVisible(true);
container.add(jpb);
container.add(fileName);
load.add(container);
for (int i = 0; i < g.list.getSelectedValues().length; i++)
{
//running code injection method addCode
fileName.setText(" Current File being injected " + g.list.getSelectedValues()[i]);
ac.injectCode(new File("files/" + g.list.getSelectedValues()[i]) ,jpb);
}
jpb.setValue(g.list.getSelectedValues().length);
load.setVisible(false);
load.dispose();