Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. GuiFrame() {
  2. setTitle("Aplikacija (bez imena) v1.0.1");
  3. setSize(800, 600);
  4. setLocationRelativeTo(null);
  5. setContentPane(new GuiPanel());
  6. setDefaultCloseOperation(EXIT_ON_CLOSE);
  7.  
  8.  
  9. setResizable(false);
  10. setLocationRelativeTo(null);
  11. setVisible(true);
  12.  
  13. }
  14.  
  15. JLabel title = new JLabel("Aplikacija za dijagnozu bolesti");
  16. JLabel diagnose = new JLabel("Preliminarna dijagnoza : ");
  17.  
  18. private final String[] listS1 = {"-Odaberi-", "Akutni", "Hronicni"};
  19. JComboBox comboS1 = new JComboBox();
  20. private int counterS1 = 0;
  21.  
  22. private final String[] listS2 = {"-Odaberi-", "Abdomen", "Udovi", "Glava"};
  23. JComboBox comboS2 = new JComboBox();
  24. private int counterS2 = 0;
  25.  
  26. private final ComboBoxModel[] models = new ComboBoxModel[5];
  27.  
  28. private final JComboBox comboS3 = new JComboBox();
  29.  
  30. JLabel simptom1 = new JLabel("Vrsta bola koju osecate : ");
  31. JLabel simptom2 = new JLabel("U kom delu tela osecate taj bol :");
  32. JLabel simptom3 = new JLabel("Vas bol osecate u (vidi sliku) : ");
  33.  
  34. public final ImageIcon rep = new ImageIcon(getClass().getResource("/images/rsz_flag_of_the_red_cross.png"));
  35. public final ImageIcon rep2 = new ImageIcon(getClass().getResource("/images/rsz_s13.jpg"));
  36. JLabel picture01 = new JLabel(rep);
  37. JLabel picture02 = new JLabel(rep2);
  38.  
  39. JTextField diagnoseField = new JTextField();
  40.  
  41. Font font = new Font("Times new Roman", Font.BOLD, 14);
  42.  
  43. JButton reset = new JButton();
  44. JButton calculate = new JButton();
  45.  
  46. public GuiPanel() {
  47.  
  48. setLayout(null);
  49.  
  50. models[0] = new DefaultComboBoxModel(new String[]{"-Odaberi-"});
  51. models[1] = new DefaultComboBoxModel(new String[]{"-Odaberi-", "1", "2", "3", "4", "5", "6", "7", "8", "9"});
  52.  
  53. title.setBounds(90, 40, 200, 100);
  54. title.setFont(font);
  55. add(title);
  56.  
  57. picture01.setBounds(400, 40, 350, 400);
  58. add(picture01);
  59.  
  60. picture02.setBounds(400, 40, 350, 400);
  61. picture02.setVisible(false);
  62. add(picture02);
  63.  
  64. simptom1.setBounds(10, 100, 200, 100);
  65. add(simptom1);
  66.  
  67. simptom2.setBounds(10, 200, 200, 100);
  68. add(simptom2);
  69.  
  70. simptom3.setBounds(10, 300, 200, 100);
  71. add(simptom3);
  72.  
  73. comboS1.setBounds(245, 135, 90, 30);
  74. for (int i = 0; i < 3; i++) {
  75. comboS1.addItem(listS1[counterS1++]);
  76. }
  77. add(comboS1);
  78.  
  79. comboS2.setBounds(245, 235, 90, 30);
  80. for (int i = 0; i < 4; i++) {
  81. comboS2.addItem(listS2[counterS2++]);
  82. }
  83. add(comboS2);
  84.  
  85. comboS3.setBounds(245, 335, 90, 30);
  86. comboS3.setModel(models[0]);
  87. comboS3.disable();
  88. add(comboS3);
  89.  
  90. diagnose.setBounds(10, 420, 200, 100);
  91. add(diagnose);
  92.  
  93. diagnoseField.setBounds(10, 490, 350, 30);
  94. diagnoseField.setEditable(false);
  95. add(diagnoseField);
  96.  
  97. reset.setText("Ponovo");
  98. reset.setBounds(640, 470, 110, 50);
  99. add(reset);
  100.  
  101. calculate.setText("Dijagnoza");
  102. calculate.setBounds(400, 470, 110, 50);
  103. calculate.addActionListener(comboS1);
  104. add(calculate);
  105.  
  106. CalculateButton c = new CalculateButton(calculate, comboS1, comboS2, comboS3, diagnoseField);
  107. AgainButton a = new AgainButton(reset, comboS1, comboS2, comboS3, diagnoseField, picture01);
  108.  
  109. again();
  110. whenAkutniAbdomen();
  111. //diagnose();
  112.  
  113. }
  114.  
  115. public class CalculateButton implements ActionListener {
  116.  
  117. private final JComboBox comboS1;
  118. private final JComboBox comboS2;
  119. private final JComboBox comboS3;
  120. private final JTextField diagnoseField;
  121.  
  122. public CalculateButton(JButton calculate, JComboBox comboS1, JComboBox comboS2, JComboBox comboS3, JTextField diagnoseField) {
  123. this.comboS1 = comboS1;
  124. this.comboS2 = comboS2;
  125. this.comboS3 = comboS3;
  126. this.diagnoseField = diagnoseField;
  127. calculate.addActionListener(this);
  128. }
  129.  
  130. @Override
  131. public void actionPerformed(ActionEvent e) {
  132.  
  133. if (comboS1.getSelectedIndex() == 1 && comboS2.getSelectedIndex() == 1 && comboS3.getSelectedIndex() == 1) {
  134. diagnoseField.setText("Rak na pluca");
  135. }
  136.  
  137. }
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement