p align="left">panel1.add(label4); panel1.add(label5); panel1.add(label6); panel1.add(label7); panel1.add(label9); replace2 = new JButton("OK"); panel.add(replace2); contentPane.add(panel,BorderLayout.SOUTH); contentPane.add(panel1,BorderLayout.CENTER); } catch (IOException e) { System.out.print("Can not read file66666"+e); } replace2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event2) { System.exit(0); } }); } private JLabel label; private JLabel label1; private JLabel label2; private JLabel label3; private JLabel label4; private JLabel label5; private JLabel label6; private JLabel label7; private JLabel label9; private JButton replace2; private String S2; private String hhh=new String(""); private int seconds_1; private int minute_1; private int hour_1; private int day_1; private int mouth_1; private int year_1; private int g; private int r34=0; private int r3=0; private DataInputStream ids13; private Device [] df; private int [] m1; private DataInputStream ids131; private Device [] newStaff1=new Device[10]; static Device[] readData(BufferedReader in) throws IOException { int n = Integer.parseInt(in.readLine()); Device [] e=new Device[n]; for(int i=0;i<n;i++) { e[i] = new Device(); e[i].readData(in); } return e; } } class MyTimer1 extends JFrame { public MyTimer1() { setSize(650,350); setTitle("His answer"); try { S2 =JOptionPane.showInputDialog("Введите логин искомого студента"); FileInputStream is12 = new FileInputStream(new File("C:\\Student\\"+S2+".txt")); ids13 = new DataInputStream(is12); String E=ids13.readUTF(); int f=Integer.parseInt(E); df=new Device[f]; m1=new int [f]; FileInputStream is121 = new FileInputStream(new File("C:\\Student1\\"+S2+".txt")); ids131 = new DataInputStream(is121); for(int r123=0;r123<f;r123++) { String E1=ids131.readUTF(); int f1=Integer.parseInt(E1); m1[r123]=f1; } BufferedReader in = new BufferedReader(new FileReader("device1.dat")); newStaff1=readData(in); in.close(); for(int g1=0;g1<f;g1++) { r3=m1[g1]; df[r34]=newStaff1[r3]; r34++; } label9= new JLabel("FFF"); for(int g1=0;g1<f;g1++) { String rrr=df[g1].getName(); hhh=hhh+"<br>"+rrr; } label9.setText("<html><br> Он правильно ответили на следующие темы(это - "+(f*10)+"%)<br>"+hhh+"</html>"); Container contentPane = getContentPane (); JPanel panel = new JPanel(); JPanel panel1 = new JPanel(); panel.add(label9); replace2 = new JButton("OK"); panel1.add(replace2); contentPane.add(panel,BorderLayout.CENTER); contentPane.add(panel1,BorderLayout.SOUTH); } catch (IOException e) { System.out.print("Can not read file66666"+e); } replace2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event2) { System.exit(0); } }); } private JLabel label9; private JButton replace2; private String S2; private String hhh=new String(""); private int r34=0; private int r3=0; private DataInputStream ids13; private Device [] df; private int [] m1; private DataInputStream ids131; private Device [] newStaff1=new Device[10]; static Device[] readData(BufferedReader in) throws IOException { int n = Integer.parseInt(in.readLine()); Device [] e=new Device[n]; for(int i=0;i<n;i++) { e[i] = new Device(); e[i].readData(in); } return e; } } class ButtonFrame11 extends JFrame { public ButtonFrame11() { Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int screenHeight = screenSize.height; int screenWidth = screenSize.width; setSize(screenWidth/3,screenHeight/5); setLocation(screenWidth/4,screenHeight/4); Image img = kit.getImage("icon.gif"); setIconImage(img); setTitle("CenteredFrame"); ButtonPanel11 panel = new ButtonPanel11(); add(panel); } } class ButtonPanel11 extends JPanel { public ButtonPanel11() { JButton BeginButton = new JButton("Begin"); JButton ReButton = new JButton("Registration"); Password = new JPasswordField("",6); login = new JTextField(15); label1 = new JLabel("Please,input your name"); label2 = new JLabel("Please,input your password"); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2,2)); panel.add (label1); panel.add (login); panel.add (label2); panel.add (Password); add(panel,BorderLayout.CENTER); JPanel panel1 = new JPanel(); panel1.add(BeginButton); panel1.add (ReButton); add(panel1,BorderLayout.SOUTH); ColorAction11 BeginAction = new ColorAction11(2); ColorAction11 ReAction = new ColorAction11(3); BeginButton.addActionListener(BeginAction); ReButton.addActionListener(ReAction); } private class ColorAction11 implements ActionListener { public ColorAction11(int c) { ccc=c; t=0; S1=new String("0"); S2=new String("1"); S3=new String("2"); S4=new String("3"); S5=new String("4"); S6=new String("5"); S7=new String("6"); S8=new String("7"); S9=new String("8"); S10=new String("9"); } public void actionPerformed(ActionEvent event) { if(ccc==2) { S13 = login.getText(); pass = Password.getPassword(); S14=new String(pass,0,6); try { FileInputStream is = new FileInputStream(new File("C:\\RGR\\"+S13+".txt")); DataInputStream ids = new DataInputStream(is); String S15=ids.readUTF(); if (S15.length() == S13.length()) { if(S13.regionMatches(0, S15, 0, S15.length())) { String S16 = ids.readUTF(); if(S13.regionMatches(0, S11, 0, S11.length())) { t1=1; } if (S14.length() == S16.length()) { if(S14.regionMatches(0, S16, 0, S16.length())) { if(S14.regionMatches(0, r, 0, r.length())) { t1=2; } FileOutputStream OS=new FileOutputStream (new File("C:\\USER\\NOW.txt")); DataOutputStream ods = new DataOutputStream (OS); ods.writeUTF(S13); ods.close(); GregorianCalendar d = new GregorianCalendar(); int year=d.get(Calendar.YEAR); int mouth=d.get(Calendar.MONTH); int day=d.get(Calendar.DAY_OF_MONTH); int hour=d.get(Calendar.HOUR); int minute=d.get(Calendar.MINUTE); int seconds=d.get(Calendar.SECOND); String S111=""+year; String S122=""+mouth; String S133=""+day; String S144=""+hour; String S155=""+minute; String S166=""+seconds; FileOutputStream OS2=new FileOutputStream (new File("C:\\USER\\Time.txt")); DataOutputStream ods2 = new DataOutputStream (OS2); ods2.writeUTF(S111); ods2.writeUTF(S122); ods2.writeUTF(S133); ods2.writeUTF(S144); ods2.writeUTF(S155); ods2.writeUTF(S166); ods2.close(); if(t1==2) { FileOutputStream OS6=new FileOutputStream (new File("C:\\USER\\teacher.txt")); DataOutputStream ods6 = new DataOutputStream (OS6); ods6.writeUTF("1"); ods6.close(); } else { FileOutputStream OS6=new FileOutputStream (new File("C:\\USER\\teacher.txt")); DataOutputStream ods6 = new DataOutputStream (OS6); ods6.writeUTF("0"); ods6.close(); } ButtonFrame frame = new ButtonFrame (); frame.setVisible(true); } } } } else { System.out.print("You full!"); } } catch (IOException e) { System.out.print("Can not read file77777"+e); } } if(ccc==3) { try{ t++; S13 = login.getText(); System.out.println(S13); pass = Password.getPassword(); System.out.println(pass); S14=new String(pass,0,6); File file = new File("C:\\RGR\\"+S13+".txt"); File file1 = new File("C:\\KURS\\"+S13+".txt"); File file2 = new File("C:\\Student\\"+S13+".txt"); File file3 = new File("C:\\Student1\\"+S13+".txt"); try { file.createNewFile(); file1.createNewFile(); file2.createNewFile(); file3.createNewFile(); } catch(IOException e) { System.out.println("Can not create new file"+e); } FileOutputStream OS=new FileOutputStream (new File("C:\\RGR\\"+S13+".txt")); DataOutputStream ods = new DataOutputStream (OS); ods.writeUTF(S13); ods.writeUTF(S14); ods.close(); FileOutputStream OS1=new FileOutputStream (new File("C:\\KURS\\"+S13+".txt")); DataOutputStream ods1 = new DataOutputStream (OS1); ods1.writeUTF(S1); ods1.writeUTF(S2); ods1.writeUTF(S3); ods1.writeUTF(S4); ods1.writeUTF(S5); ods1.writeUTF(S6); ods1.writeUTF(S7);
Страницы: 1, 2, 3, 4
|