Hi ezra,
i'm somewhat learning java as well (haven't really fiddled with it for some time til now). i was able to get the printout for your coding (System.out.println) but the issue that pops up deals with the number 0 showing on top of the console print out..hope this helps
Code:
import java.util.ArrayList;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class CodingForums extends JFrame{
static ArrayList<String> firstname = new ArrayList<String>();
static ArrayList<String> lastname = new ArrayList<String>();
static ArrayList<String> address = new ArrayList<String>();
static ArrayList<String> city = new ArrayList<String>();
static ArrayList<String> state = new ArrayList<String>();
static ArrayList<String> zipcode = new ArrayList<String>();
public static void main(String [] args){
JTextField field1 = new JTextField(2),
field2 = new JTextField(2),
field3 = new JTextField(2);
JTextField field4 = new JTextField(2),
field5 = new JTextField(2),
field6 = new JTextField(2);
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
pane1.add(new JLabel("First name: "));
pane1.add(field1);
pane1.add(Box.createHorizontalStrut(10));
pane1.add(new JLabel ("Last name: "));
pane1.add(field2);
pane1.add(Box.createHorizontalStrut(10));
pane1.add(new JLabel("Street Address: "));
pane1.add(field3);
pane1.add(Box.createHorizontalStrut(10));
pane1.add(new JLabel("City: "));
pane1.add(field4);
pane1.add(Box.createHorizontalStrut(10));
pane1.add(new JLabel("State: "));
pane1.add(field5);
pane1.add(Box.createHorizontalStrut(10));
pane1.add(new JLabel("ZIP code: "));
pane1.add(field6);
int personinput = JOptionPane.showConfirmDialog(null, pane1, "Please enter your:", JOptionPane.OK_CANCEL_OPTION);
System.out.println(personinput);
if (personinput == JOptionPane.CANCEL_OPTION)
{
JOptionPane.showMessageDialog(null, "You must enter your information to vote.");
main(args);
}
for(int x = personinput; x==JOptionPane.OK_OPTION; x++)
{
firstname.add(field1.getText());
lastname.add(field2.getText());
address.add(field3.getText());
city.add(field4.getText());
state.add(field5.getText());
zipcode.add(field6.getText());
mainstuff();
}
}
private static void mainstuff() {
// TODO Auto-generated method stub
System.out.println(firstname);
System.out.println(lastname);
System.out.println(zipcode);
}
}