package javafinal; /////////////////////////////////////// import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import static javax.swing.JFrame.*; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; /////////////////////////////////////// public class JavaFinal extends JFrame implements ActionListener{ private String[] arrSch = new String[4]; private Label lblUser; private TextField txtUser; private Label lblSch; private JComboBox jcbSch; private Label lblPass; private JPasswordField pwfPass; private JButton logBut; private JButton extBut; private JButton regBut; HashMap map = new HashMap(); /////////////////////////////////////// public JavaFinal() throws IOException{ arrSch[0]="CCAC West"; arrSch[1]="CCAC North"; arrSch[2]="CCAC South"; arrSch[3]="CCAC Main"; ///////////////////////////////////////////////// /*map.put(' ', 0); map.put('a', 1); map.put('b', 2); map.put('c', 3); map.put('d', 4); map.put('e', 5); map.put('f', 6); map.put('g', 7); map.put('h', 8); map.put('i', 9); map.put('j', 10); map.put('k', 11); map.put('l', 12); map.put('m', 13); map.put('n', 14); map.put('o', 15); map.put('p', 16); map.put('q', 17); map.put('r', 18); map.put('s', 19); map.put('t', 20); map.put('u', 21); map.put('v', 22); map.put('w', 23); map.put('x', 24); map.put('y', 25); map.put('z', 26); map.put(';', 27);*/ ///////////////////////////////////////////////// setLayout(new FlowLayout()); lblUser = new Label("Username: "); add(lblUser); txtUser = new TextField(null,10); add(txtUser); lblSch = new Label("School: "); add(lblSch); jcbSch = new JComboBox(arrSch); add(jcbSch); lblPass = new Label("Password: "); add(lblPass); pwfPass = new JPasswordField("",10); add(pwfPass); logBut = new JButton("Login"); add(logBut); extBut = new JButton("Exit"); add(extBut); regBut = new JButton("Register"); add(regBut); /////////////////////////////// setTitle("Login"); setSize(240,180 ); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); extBut.addActionListener(e -> System.exit(0)); regBut.addActionListener(new RegisterListener()); } /////////////////////////////////////// /** *Prints to the selected file using the fileWrite method */ public class RegisterListener implements ActionListener{ public void actionPerformed(ActionEvent e){ try { fileWrite(txtUser.getText(),jcbSch.getSelectedItem().toString(),pwfPass.getPassword()); } catch (FileNotFoundException ex) { e.toString(); } } } /////////////////////////////////////// /*public class RegisterListener2 implements ActionListener{ char[] u = txtUser.getText().toLowerCase().toCharArray(); int s = jcbSch.getSelectedIndex(); char[] p = pwfPass.getPassword(); int val=1; public void actionPerformed(ActionEvent e){ for(int i = 0;i map3 = new HashMap(); while (scan.hasNextLine()){ String[] colums = scan.nextLine().split(","); map3.put(colums[0],0); } String line = read.readLine(); } /////////////////////////////////////// }