Hello All,
I’m in the process of making a GUI for a program that I wrote. What I want to do is take the character string that the user types into the text field and use it in main() like a regular string. Excuse me if this problem has been addressed in the past.
Here is my GUI thus far: Thanks to all those who respond.
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class GUITest extends JFrame {
private String text;
private static String filename;
public GUITest() {
super("LaTeX Template.exe");
setSize(300,300);
FlowLayout flo = new FlowLayout();
setLayout(flo);
JLabel Title = new JLabel("Doc Title:", JLabel.RIGHT);
add(Title);
JTextField text = new JTextField(20);
add(text);
JButton Create = new JButton("Create!");
add(Create);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("Create!")) {
filename = "Hello";
}
}
public static void main(String args[]) {
GUITest Temp = new GUITest();
if (filename != null) {
System.out.print(filename);
}
}
}