I have two classes. 1.One class contains all the GUI code generated by Netbeans GUI builder (call it GUI class) 2.Another class contains some code containing methods (SaveTraffic which extends SwingWorker).
In my SaveTraffic , I create a frame which just pops up and come in front of my GUI when I run my application. I want to add this frame to my GUI at the specific location where I want to place it. How is this possible? This is my code of SaveTraffic
public class SaveTraffic extends SwingWorker<Void, String> {
public static int k = 0;
public GUI f = new GUI();
public static Frame u = new Frame();
public static JTextArea h = new JTextArea();
JScrollPane scrollPane2 = new JScrollPane(h, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
@Override
public Void doInBackground() throws IOException {
u.setSize(950, 200);
u.setLocation(0,550);
u.add(scrollPane2);
u.setVisible(true);
while (f.num() != 2) {
{
publish("Hello World");
}
}
return null;
} //end main function
@Override
public void process(List<String> chunks) {
for (final String text : chunks) {
Runnable r = new Runnable() {
@Override
public void run() {
h.setLineWrap(true);
h.append(text + "\n");
}
};
new Thread(r).start();
}
}
@Override
public void done() {
System.out.println("I am DONE");
}
}