| 1 package demo.poa_monitor.client; 2 3 4 5 10 11 public class TestFrame extends java.awt.Frame implements java.awt.event.ActionListener , java.awt.event.AdjustmentListener , java.awt.event.WindowListener { 12 13 private java.awt.Panel ivjButtonPanel = null; 14 15 private java.awt.FlowLayout ivjButtonPanelFlowLayout = null; 16 17 private java.awt.Label ivjComputationLabel = null; 18 19 private java.awt.Panel ivjContentsPane = null; 20 21 private java.awt.Label ivjInvocationLabel = null; 22 23 private java.awt.Label ivjNumberLabel = null; 24 25 private java.awt.TextField ivjNumberTextField = null; 26 27 private java.awt.Label ivjSpeedLabel = null; 28 29 private java.awt.Scrollbar ivjSpeedScrollbar = null; 30 31 private java.awt.Label ivjThreadsLabel = null; 32 33 private java.awt.TextField ivjThreadsTextField = null; 34 35 private java.awt.Button ivjCancelButton = null; 36 37 private java.awt.Button ivjStartButton = null; 38 39 private java.awt.Button ivjStopButton = null; 40 41 private java.awt.Panel ivjWorkPanel = null; 42 43 private java.awt.Label ivjCostLabel = null; 44 45 private java.awt.Scrollbar ivjCostScrollbar = null; 46 47 private java.awt.Label ivjDescriptionLabel = null; 48 49 private java.awt.Label ivjServerLabel = null; 50 51 private java.awt.BorderLayout ivjContentsPaneBorderLayout = null; 52 53 private java.awt.BorderLayout ivjTestFrameBorderLayout = null; 54 55 60 61 62 63 public TestFrame() { 64 65 super(); 66 67 initialize(); 68 69 } 70 71 78 79 public TestFrame(String title) { 80 81 super(title); 82 83 } 84 85 private void _actionCancelButtonPressed() { 86 87 Client.actionCancel(); 88 89 } 90 91 private void _actionCostbarValueChanged(int value) { 92 93 if (value == 0) { 94 95 getCostLabel().setText("no cost"); 96 97 Client.cost = value; 98 99 100 101 } else if (value < 11) { 102 103 getCostLabel().setText("0 - "+((value)*100)+" msec"); 104 105 Client.cost = value*100; 106 107 108 109 } else { 110 111 getCostLabel().setText("0 - "+((value)*200)+" msec"); 112 113 Client.cost = value*200; 114 115 } 116 117 } 118 119 private void _actionSpeedbarValueChanged(int value) { 120 121 if (value == 0) { 122 123 getSpeedLabel().setText("no delay"); 124 125 Client.speed = value; 126 127 128 129 } else if (value < 11) { 130 131 getSpeedLabel().setText("0 - "+((value)*100)+" msec"); 132 133 Client.speed = value*100; 134 135 136 137 } else { 138 139 getSpeedLabel().setText("0 - "+((value)*200)+" msec"); 140 141 Client.speed = value*200; 142 143 } 144 145 } 146 147 private void _actionStartButtonPressed(String objects, String threads) { 148 149 getNumberLabel().setEnabled(false); 150 151 getNumberTextField().setEnabled(false); 152 153 getThreadsLabel().setEnabled(false); 154 155 getThreadsTextField().setEnabled(false); 156 157 getStartButton().setEnabled(false); 158 159 160 161 Client.actionStart(Integer.parseInt(objects), Integer.parseInt(threads)); 162 163 } 164 165 private void _actionStopButtonPressed() { 166 167 getNumberLabel().setEnabled(true); 168 169 getNumberTextField().setEnabled(true); 170 171 getThreadsLabel().setEnabled(true); 172 173 getThreadsTextField().setEnabled(true); 174 175 getStartButton().setEnabled(true); 176 177 178 179 Client.actionStop(); 180 181 } 182 183 190 191 192 193 public void actionPerformed(java.awt.event.ActionEvent e) { 194 195 197 199 if ((e.getSource() == getStartButton()) ) { 200 201 connEtoC4(e); 202 203 } 204 205 if ((e.getSource() == getStopButton()) ) { 206 207 connEtoC5(e); 208 209 } 210 211 if ((e.getSource() == getCancelButton()) ) { 212 213 connEtoC6(e); 214 215 } 216 217 219 221 } 222 223 230 231 232 233 public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e) { 234 235 237 239 if ((e.getSource() == getSpeedScrollbar()) ) { 240 241 connEtoC2(e); 242 243 } 244 245 if ((e.getSource() == getCostScrollbar()) ) { 246 247 connEtoC3(e); 248 249 } 250 251 253 255 } 256 257 264 265 266 267 private void connEtoC1(java.awt.event.WindowEvent arg1) { 268 269 try { 270 271 273 275 this.dispose(); 276 277 279 281 } catch (java.lang.Throwable ivjExc) { 282 283 285 287 handleException(ivjExc); 288 289 } 290 291 } 292 293 300 301 302 303 private void connEtoC2(java.awt.event.ActionEvent arg1) { 304 305 try { 306 307 309 311 this._actionCancelButtonPressed(); 312 313 315 317 } catch (java.lang.Throwable ivjExc) { 318 319 321 323 handleException(ivjExc); 324 325 } 326 327 } 328 329 336 337 338 339 private void connEtoC2(java.awt.event.AdjustmentEvent arg1) { 340 341 try { 342 343 345 347 this._actionSpeedbarValueChanged(getSpeedScrollbar().getValue()); 348 349 351 353 } catch (java.lang.Throwable ivjExc) { 354 355 357 359 handleException(ivjExc); 360 361 } 362 363 } 364 365 372 373 374 375 private void connEtoC3(java.awt.event.ActionEvent arg1) { 376 377 try { 378 379 381 383 this._actionStopButtonPressed(); 384 385 387 389 } catch (java.lang.Throwable ivjExc) { 390 391 393 395 handleException(ivjExc); 396 397 } 398 399 } 400 401 408 409 410 411 private void connEtoC3(java.awt.event.AdjustmentEvent arg1) { 412 413 try { 414 415 417 419 this._actionCostbarValueChanged(getCostScrollbar().getValue()); 420 421 423 425 } catch (java.lang.Throwable ivjExc) { 426 427 429 431 handleException(ivjExc); 432 433 } 434 435 } 436 437 444 445 446 447 private void connEtoC4(java.awt.event.ActionEvent arg1) { 448 449 try { 450 451 453 455 this._actionStartButtonPressed(getNumberTextField().getText(), getThreadsTextField().getText()); 456 457 459 461 } catch (java.lang.Throwable ivjExc) { 462 463 465 467 handleException(ivjExc); 468 469 } 470 471 } 472 473 480 481 482 483 private void connEtoC5(java.awt.event.ActionEvent arg1) { 484 485 try { 486 487 489 491 this._actionStopButtonPressed(); 492 493 495 497 } catch (java.lang.Throwable ivjExc) { 498 499 501 503 handleException(ivjExc); 504 505 } 506 507 } 508 509 516 517 518 519 private void connEtoC5(java.awt.event.AdjustmentEvent arg1) { 520 521 try { 522 523 525 527 this._actionSpeedbarValueChanged(getSpeedScrollbar().getValue()); 528 529 531 533 } catch (java.lang.Throwable ivjExc) { 534 535 537 539 handleException(ivjExc); 540 541 } 542 543 } 544 545 552 553 554 555 private void connEtoC6(java.awt.event.ActionEvent arg1) { 556 557 try { 558 559 561 563 this._actionCancelButtonPressed(); 564 565 567 569 } catch (java.lang.Throwable ivjExc) { 570 571 573 575 handleException(ivjExc); 576 577 } 578 579 } 580 581 588 589 590 591 private void connEtoC6(java.awt.event.AdjustmentEvent arg1) { 592 593 try { 594 595 597 599 this._actionCostbarValueChanged(getCostScrollbar().getValue()); 600 601 603 605 } catch (java.lang.Throwable ivjExc) { 606 607 609 611 handleException(ivjExc); 612 613 } 614 615 } 616 617 624 625 626 627 private java.awt.Panel getButtonPanel() { 628 629 if (ivjButtonPanel == null) { 630 631 try { 632 633 ivjButtonPanel = new java.awt.Panel (); 634 635 ivjButtonPanel.setName("ButtonPanel"); 636 637 ivjButtonPanel.setLayout(getButtonPanelFlowLayout()); 638 639 ivjButtonPanel.setBackground(java.awt.SystemColor.control); 640 641 getButtonPanel().add(getStartButton(), getStartButton().getName()); 642 643 getButtonPanel().add(getStopButton(), getStopButton().getName()); 644 645 getButtonPanel().add(getCancelButton(), getCancelButton().getName()); 646 647 649 651 } catch (java.lang.Throwable ivjExc) { 652 653 655 657 handleException(ivjExc); 658 659 } 660 661 }; 662 663 return ivjButtonPanel; 664 665 } 666 667 674 675 676 677 private java.awt.FlowLayout getButtonPanelFlowLayout() { 678 679 java.awt.FlowLayout ivjButtonPanelFlowLayout = null; 680 681 try { 682 683 684 685 ivjButtonPanelFlowLayout = new java.awt.FlowLayout (); 686 687 ivjButtonPanelFlowLayout.setAlignment(java.awt.FlowLayout.RIGHT); 688 689 ivjButtonPanelFlowLayout.setVgap(5); 690 691 ivjButtonPanelFlowLayout.setHgap(10); 692 693 } catch (java.lang.Throwable ivjExc) { 694 695 handleException(ivjExc); 696 697 }; 698 699 return ivjButtonPanelFlowLayout; 700 701 } 702 703 710 711 712 713 private java.awt.Button getCancelButton() { 714 715 if (ivjCancelButton == null) { 716 717 try { 718 719 ivjCancelButton = new java.awt.Button (); 720 721 ivjCancelButton.setName("CancelButton"); 722 723 ivjCancelButton.setBackground(java.awt.SystemColor.control); 724 725 ivjCancelButton.setActionCommand(" Cancel "); 726 727 ivjCancelButton.setLabel(" Cancel "); 728 729 731 733 } catch (java.lang.Throwable ivjExc) { 734 735 737 739 handleException(ivjExc); 740 741 } 742 743 }; 744 745 return ivjCancelButton; 746 747 } 748 749 756 757 758 759 private java.awt.Label getComputationLabel() { 760 761 if (ivjComputationLabel == null) { 762 763 try { 764 765 ivjComputationLabel = new java.awt.Label (); 766 767 ivjComputationLabel.setName("ComputationLabel"); 768 769 ivjComputationLabel.setLocation(new java.awt.Point (20, 185)); 770 771 ivjComputationLabel.setText("Computation cost on server"); 772 773 ivjComputationLabel.setBackground(java.awt.SystemColor.control); 774 775 ivjComputationLabel.setSize(new java.awt.Dimension (130, 12)); 776 777 ivjComputationLabel.setForeground(java.awt.Color.black); 778 779 ivjComputationLabel.setFont(new java.awt.Font ("dialog", 2, 10)); 780 781 ivjComputationLabel.setBounds(new java.awt.Rectangle (20, 185, 130, 12)); 782 783 ivjComputationLabel.setAlignment(java.awt.Label.LEFT); 784 785 ivjComputationLabel.setBounds(20, 185, 130, 12); 786 787 789 791 } catch (java.lang.Throwable ivjExc) { 792 793 795 797 handleException(ivjExc); 798 799 } 800 801 }; 802 803 return ivjComputationLabel; 804 805 } 806 807 814 815 816 817 private java.awt.Panel getContentsPane() { 818 819 if (ivjContentsPane == null) { 820 821 try { 822 823 ivjContentsPane = new java.awt.Panel (); 824 825 ivjContentsPane.setName("ContentsPane"); 826 827 ivjContentsPane.setLayout(getContentsPaneBorderLayout()); 828 829 ivjContentsPane.setBackground(java.awt.SystemColor.control); 830 831 getContentsPane().add(getButtonPanel(), "South"); 832 833 getContentsPane().add(getWorkPanel(), "Center"); 834 835 837 839 } catch (java.lang.Throwable ivjExc) { 840 841 843 845 handleException(ivjExc); 846 847 } 848 849 }; 850 851 return ivjContentsPane; 852 853 } 854 855 862 863 864 865 private java.awt.BorderLayout getContentsPaneBorderLayout() { 866 867 java.awt.BorderLayout ivjContentsPaneBorderLayout = null; 868 869 try { 870 871 872 873 ivjContentsPaneBorderLayout = new java.awt.BorderLayout (); 874 875 ivjContentsPaneBorderLayout.setVgap(0); 876 877 ivjContentsPaneBorderLayout.setHgap(0); 878 879 } catch (java.lang.Throwable ivjExc) { 880 881 handleException(ivjExc); 882 883 }; 884 885 return ivjContentsPaneBorderLayout; 886 887 } 888 889 896 897 898 899 private java.awt.Label getCostLabel() { 900 901 if (ivjCostLabel == null) { 902 903 try { 904 905 ivjCostLabel = new java.awt.Label (); 906 907 ivjCostLabel.setName("CostLabel"); 908 909 ivjCostLabel.setLocation(new java.awt.Point (170, 197)); 910 911 ivjCostLabel.setText("no cost"); 912 913 ivjCostLabel.setBackground(java.awt.SystemColor.control); 914 915 ivjCostLabel.setSize(new java.awt.Dimension (80, 23)); 916 917 ivjCostLabel.setForeground(java.awt.Color.red); 918 919 ivjCostLabel.setFont(new java.awt.Font ("dialog", 1, 12)); 920 921 ivjCostLabel.setBounds(new java.awt.Rectangle (170, 197, 80, 23)); 922 923 ivjCostLabel.setAlignment(2); 924 925 ivjCostLabel.setBounds(150, 197, 100, 23); 926 927 929 931 } catch (java.lang.Throwable ivjExc) { 932 933 935 937 handleException(ivjExc); 938 939 } 940 941 }; 942 943 return ivjCostLabel; 944 945 } 946 947 954 955 956 957 private java.awt.Scrollbar getCostScrollbar() { 958 959 if (ivjCostScrollbar == null) { 960 961 try { 962 963 ivjCostScrollbar = new java.awt.Scrollbar (); 964 965 ivjCostScrollbar.setName("CostScrollbar"); 966 967 ivjCostScrollbar.setLocation(new java.awt.Point (20, 200)); 968 969 ivjCostScrollbar.setSize(new java.awt.Dimension (130, 18)); 970 971 ivjCostScrollbar.setBounds(new java.awt.Rectangle (20, 200, 130, 18)); 972 973 ivjCostScrollbar.setBounds(20, 200, 120, 18); 974 975 ivjCostScrollbar.setOrientation(java.awt.Scrollbar.HORIZONTAL); 976 977 979 981 } catch (java.lang.Throwable ivjExc) { 982 983 985 987 handleException(ivjExc); 988 989 } 990 991 }; 992 993 return ivjCostScrollbar; 994 995 } 996 997 1004 1005 1006 1007private java.awt.Label getDescriptionLabel() { 1008 1009 if (ivjDescriptionLabel == null) { 1010 1011 try { 1012 1013 ivjDescriptionLabel = new java.awt.Label (); 1014 1015 ivjDescriptionLabel.setName("DescriptionLabel"); 1016 1017 ivjDescriptionLabel.setLocation(new java.awt.Point (10, 35)); 1018 1019 ivjDescriptionLabel.setText("description not available"); 1020 1021 ivjDescriptionLabel.setBackground(java.awt.SystemColor.control); 1022 1023 ivjDescriptionLabel.setSize(new java.awt.Dimension (260, 23)); 1024 1025 ivjDescriptionLabel.setForeground(java.awt.Color.black); 1026 1027 ivjDescriptionLabel.setFont(new java.awt.Font ("dialog", 3, 12)); 1028 1029 ivjDescriptionLabel.setBounds(new java.awt.Rectangle (10, 35, 260, 23)); 1030 1031 ivjDescriptionLabel.setAlignment(1); 1032 1033 ivjDescriptionLabel.setBounds(10, 35, 260, 23); 1034 1035 1037 1039 } catch (java.lang.Throwable ivjExc) { 1040 1041 1043 1045 handleException(ivjExc); 1046 1047 } 1048 1049 }; 1050 1051 return ivjDescriptionLabel; 1052 1053} 1054 1055 1062 1063 1064 1065private java.awt.Label getInvocationLabel() { 1066 1067 if (ivjInvocationLabel == null) { 1068 1069 try { 1070 1071 ivjInvocationLabel = new java.awt.Label (); 1072 1073 ivjInvocationLabel.setName("InvocationLabel"); 1074 1075 ivjInvocationLabel.setLocation(new java.awt.Point (20, 145)); 1076 1077 ivjInvocationLabel.setText("Invocation delay on client"); 1078 1079 ivjInvocationLabel.setBackground(java.awt.SystemColor.control); 1080 1081 ivjInvocationLabel.setSize(new java.awt.Dimension (130, 12)); 1082 1083 ivjInvocationLabel.setForeground(java.awt.Color.black); 1084 1085 ivjInvocationLabel.setFont(new java.awt.Font ("dialog", 2, 10)); 1086 1087 ivjInvocationLabel.setBounds(new java.awt.Rectangle (20, 145, 130, 12)); 1088 1089 ivjInvocationLabel.setAlignment(java.awt.Label.LEFT); 1090 1091 ivjInvocationLabel.setBounds(20, 145, 130, 12); 1092 1093 1095 1097 } catch (java.lang.Throwable ivjExc) { 1098 1099 1101 1103 handleException(ivjExc); 1104 1105 } 1106 1107 }; 1108 1109 return ivjInvocationLabel; 1110 1111} 1112 1113 1120 1121 1122 1123private java.awt.Label getNumberLabel() { 1124 1125 if (ivjNumberLabel == null) { 1126 1127 try { 1128 1129 ivjNumberLabel = new java.awt.Label (); 1130 1131 ivjNumberLabel.setName("NumberLabel"); 1132 1133 ivjNumberLabel.setLocation(new java.awt.Point (20, 70)); 1134 1135 ivjNumberLabel.setText("Number of objects:"); 1136 1137 ivjNumberLabel.setBackground(java.awt.SystemColor.control); 1138 1139 ivjNumberLabel.setSize(new java.awt.Dimension (110, 23)); 1140 1141 ivjNumberLabel.setFont(new java.awt.Font ("dialog", 2, 12)); 1142 1143 ivjNumberLabel.setBounds(new java.awt.Rectangle (20, 70, 110, 23)); 1144 1145 ivjNumberLabel.setBounds(20, 70, 110, 23); 1146 1147 1149 1151 } catch (java.lang.Throwable ivjExc) { 1152 1153 1155 1157 handleException(ivjExc); 1158 1159 } 1160 1161 }; 1162 1163 return ivjNumberLabel; 1164 1165} 1166 1167 1174 1175 1176 1177private java.awt.TextField getNumberTextField() { 1178 1179 if (ivjNumberTextField == null) { 1180 1181 try { 1182 1183 ivjNumberTextField = new java.awt.TextField (); 1184 1185 ivjNumberTextField.setName("NumberTextField"); 1186 1187 ivjNumberTextField.setLocation(new java.awt.Point (170, 70)); 1188 1189 ivjNumberTextField.setText("1"); 1190 1191 ivjNumberTextField.setBackground(java.awt.Color.white); 1192 1193 ivjNumberTextField.setSize(new java.awt.Dimension (80, 23)); 1194 1195 ivjNumberTextField.setBounds(new java.awt.Rectangle (170, 70, 80, 23)); 1196 1197 ivjNumberTextField.setBounds(170, 66, 80, 30); 1198 1199 1201 &
|