Объектно-ориентированное программирование

JButton greenButton = new JButton("I_want_to_see");

JButton blueButton = new JButton("I am a teacher");

JButton redButton = new JButton("Check_Knowlarge");

JButton ExitButton = new JButton("Exit");

JPanel wer= new JPanel();

wer.add(yellowButton);

wer.add (blueButton);

wer.add(redButton);

wer.add(ExitButton);

wer.add(gre

enButton);

//contantPane.add(wer,BorderLayout.SOUTH);

contantPane.add(menuBar,BorderLayout.NORTH);

ColorAction yellowAction = new ColorAction(2);

ColorAction blueAction = new ColorAction(3);

ColorAction redAction = new ColorAction(4);

ColorAction ExitAction = new ColorAction(5);

ColorAction greenAction = new ColorAction(6);

yellowButton.addActionListener(yellowAction);

blueButton.addActionListener(blueAction);

redButton.addActionListener(redAction);

ExitButton.addActionListener(ExitAction);

greenButton.addActionListener(greenAction);

WorkSpace.addActionListener(yellowAction);

JMenuItem Check = new JMenuItem("Проверить знания",new ImageIcon("icon_security.gif"));

stMenu.add(Check);

Check.addActionListener(redAction);

JMenuItem Exit = new JMenuItem("Выход",new ImageIcon("action_stop.gif"));

stMenu.add(Exit);

Exit.addActionListener(ExitAction);

JMenu prMenu = new JMenu("Преподаватель");

JMenuItem teacher = new JMenuItem("Изменить",new ImageIcon("page_down.gif"));

prMenu.add(teacher);

teacher.addActionListener(blueAction);

JMenuItem teacher1 = new JMenuItem("Посмотреть",new ImageIcon("icon_world_dynamic.gif"));

prMenu.add(teacher1);

teacher1.addActionListener(greenAction);

menuBar.add(prMenu);

try

{

FileInputStream is = new

FileInputStream(new

File("C:\\USER\\teacher.txt"));

DataInputStream ids = new DataInputStream(is);

String S2=ids.readUTF();

n=Integer.parseInt(S2);

}

catch(IOException exception){

System.out.println("bgbvhgfj");

}

if(n==0)

{

teacher.setEnabled(false);

teacher1.setEnabled(false);

System.out.println(n);

}

else

{

Check.setEnabled(false);

Exit.setEnabled(false);

System.out.println(n);

}

}

private class ColorAction implements ActionListener

{

public ColorAction(int c)

{

ccc=c;

}

public void actionPerformed(ActionEvent event)

{

if(ccc==2)

{

JFrame1 frame2 = new JFrame1 ();

frame2.setVisible(true);

}

if(ccc==3)

{

JFrame2 frame3 = new JFrame2 ();

frame3.setVisible(true);

}

if(ccc==4)

{

CheckBoxFrame frame3 = new CheckBoxFrame();

frame3.setVisible(true);

}

if(ccc==5)

{

MyTimer frame3 = new MyTimer();

frame3.setVisible(true);

}

if(ccc==6)

{

MyTimer1 frame3 = new MyTimer1();

frame3.setVisible(true);

}

}

private int ccc;

}

private int n=0;

}

class MyTimer extends JFrame

{

public MyTimer()

{

setSize(650,350);

setTitle("Your answer");

try

{

FileInputStream is = new

FileInputStream(new

File("C:\\USER\\NOW.txt"));

DataInputStream ids = new DataInputStream(is);

S2=ids.readUTF();

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);

FileInputStream is1 = new

FileInputStream(new

File("C:\\USER\\Time.txt"));

DataInputStream ids1 = new DataInputStream(is1);

String S22=ids1.readUTF();

int year_0=Integer.parseInt(S22);

String S33=ids1.readUTF();

int mouth_0=Integer.parseInt(S33);

String S44=ids1.readUTF();

int day_0=Integer.parseInt(S44);

String S55=ids1.readUTF();

int hour_0=Integer.parseInt(S55);

String S66=ids1.readUTF();

int minute_0=Integer.parseInt(S66);

String S77=ids1.readUTF();

int seconds_0=Integer.parseInt(S77);

if(seconds<seconds_0)

{

seconds_1=seconds-seconds_0+60;

minute=minute-1;

}

else

{

seconds_1=seconds-seconds_0;

}

if(minute<minute_0)

{

minute_1=minute-minute_0+60;

hour=hour-1;

}

else

{

minute_1=minute-minute_0;

}

if(hour<hour_0)

{

hour_1=hour-hour_0+24;

day=day-1;

}

else

{

hour_1=hour-hour_0;

}

if(day<day_0)

{

if(mouth==0||mouth==2||mouth==4||mouth==6||mouth==8||mouth==10)

g=31;

if(mouth==3||mouth==5||mouth==7||mouth==9||mouth==11)

g=30;

if(mouth==1)

g=28;

if(mouth==1 && year==2012)

g=29;

day_1=day-day_0+g;

mouth=mouth-1;

}

else

{

day_1=day-day_0;

}

if(mouth<mouth_0)

{

mouth_1=mouth - mouth_0+12;

year=year-1;

}

else

{

mouth_1=mouth - mouth_0;

}

year_1=year-year_0;

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();

label = new JLabel ("Вниманиe "+S2+" , вы прошли тестирование");

label1 = new JLabel ("Ваше время пребывания:");

label2 = new JLabel (year_1+" лет ");

label3 = new JLabel (mouth_1+" месяцев ");

label4 = new JLabel (day_1+" дней ");

label5 = new JLabel (hour_1+" часов ");

label6 = new JLabel (minute_1+" минут ");

label7 = new JLabel (seconds_1+" секунд ");

contentPane.add(label,BorderLayout.NORTH);

panel1.add(label1);

panel1.add(label2);

panel1.add(label3);

panel1.add(label4);

panel1.add(label5);

panel1.add(label6);

panel1.add(label7);

Страница:  1  2  3  4  5  6  7 


Другие рефераты на тему «Программирование, компьютеры и кибернетика»:

Поиск рефератов

Последние рефераты раздела

Copyright © 2010-2024 - www.refsru.com - рефераты, курсовые и дипломные работы