I am new to java from C #, so I am not familiar with the best Java practices.
I have a main class that opens a JFrame to receive multiple input lines from a user. When the user clicks the submit button, the GUI should close and the main class continues processing using input.
This is the main class:
public class Main { FInput fInput; public void main(String[] args) { if(args.length==0) { fInput = new FInput(); fInput.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fInput.pack(); fInput.setVisible(true); } else startProcess(args); } public void startProcess(String[] args) {
The main class will use this frame to get input from the user:
public class FInput extends JFrame{ private JTextField txtSourceDirectory; private JTextField txtTargetDirectory; private JTextField txtDefectNumber; private JTextField txtSliceTokens; private JButton btnStart; public FInput() {
In all the examples that I could find, the listener will be FMain itself. However, in this case, I want Main to listen and use input in the startProcess method.
Will the main ActionListener tool, and pass it to the FMain constructor, is that the way to go?
Yoav
source share