├── .gitignore ├── LICENCE ├── README.md ├── TimingFramework-0.55.jar ├── build.xml ├── manifest.mf ├── nbproject ├── build-impl.xml ├── genfiles.properties ├── project.properties └── project.xml └── src ├── button └── Button.java ├── passwordfield └── PasswordField.java ├── swing └── shadow │ ├── GraphicsUtilities.java │ ├── ShadowRenderer.java │ └── util │ └── RippleEffect.java ├── test ├── Test.form ├── Test.java ├── Test_TextField.form └── Test_TextField.java └── textfield └── TextField.java /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /nbproject/private/ -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Raven Laing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # raven-swing-ui-component 2 | 3 | ![2022-11-06_004532](https://user-images.githubusercontent.com/58245926/200134880-8b638b78-105d-46c4-89a4-fc373db22d96.png) 4 | ![2022-11-09_105831](https://user-images.githubusercontent.com/58245926/200815070-26558dce-8096-4e67-8306-898206c7e18e.png) 5 | -------------------------------------------------------------------------------- /TimingFramework-0.55.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/raven-swing-ui-component/c247179cd609d0b236f648c79e8b52b602c9f0e3/TimingFramework-0.55.jar -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project swing-ui-component. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /nbproject/build-impl.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | Must set platform.home 148 | Must set platform.bootcp 149 | Must set platform.java 150 | Must set platform.javac 151 | 152 | The J2SE Platform is not correctly set up. 153 | Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. 154 | Either open the project in the IDE and setup the Platform with the same name or add it manually. 155 | For example like this: 156 | ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) 157 | or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | Must set src.dir 314 | Must set test.src.dir 315 | Must set build.dir 316 | Must set dist.dir 317 | Must set build.classes.dir 318 | Must set dist.javadoc.dir 319 | Must set build.test.classes.dir 320 | Must set build.test.results.dir 321 | Must set build.classes.excludes 322 | Must set dist.jar 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | Must set javac.includes 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | No tests executed. 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | Must set JVM to use for profiling in profiler.info.jvm 856 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent 857 | 858 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | Must select some files in the IDE or set javac.includes 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | To run this application from the command line without Ant, try: 1226 | 1227 | ${platform.java} -jar "${dist.jar.resolved}" 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | Must select one file in the IDE or set run.class 1366 | 1367 | 1368 | 1369 | Must select one file in the IDE or set run.class 1370 | 1371 | 1372 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | Must select one file in the IDE or set debug.class 1397 | 1398 | 1399 | 1400 | 1401 | Must select one file in the IDE or set debug.class 1402 | 1403 | 1404 | 1405 | 1406 | Must set fix.includes 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1418 | 1421 | 1422 | This target only works when run from inside the NetBeans IDE. 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | Must select one file in the IDE or set profile.class 1432 | This target only works when run from inside the NetBeans IDE. 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | This target only works when run from inside the NetBeans IDE. 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | This target only works when run from inside the NetBeans IDE. 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1475 | 1476 | 1477 | 1478 | 1479 | 1480 | 1481 | 1482 | 1483 | 1484 | 1485 | 1486 | 1487 | 1488 | Must select one file in the IDE or set run.class 1489 | 1490 | 1491 | 1492 | 1493 | 1494 | Must select some files in the IDE or set test.includes 1495 | 1496 | 1497 | 1498 | 1499 | Must select one file in the IDE or set run.class 1500 | 1501 | 1502 | 1503 | 1504 | Must select one file in the IDE or set applet.url 1505 | 1506 | 1507 | 1508 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 | 1536 | 1537 | 1538 | 1539 | 1540 | 1541 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 | 1553 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | 1560 | 1561 | 1562 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1595 | 1596 | 1597 | 1598 | 1599 | 1600 | 1601 | 1602 | 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | 1620 | 1621 | 1622 | 1623 | 1624 | 1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 | 1633 | 1634 | 1635 | 1636 | 1637 | 1638 | 1639 | 1640 | 1641 | 1642 | 1643 | 1644 | 1645 | Must select some files in the IDE or set javac.includes 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | 1655 | 1656 | 1657 | 1658 | 1659 | 1660 | 1661 | 1666 | 1667 | 1668 | 1669 | 1670 | 1671 | 1672 | 1673 | Some tests failed; see details above. 1674 | 1675 | 1676 | 1677 | 1678 | 1679 | 1680 | 1681 | 1682 | Must select some files in the IDE or set test.includes 1683 | 1684 | 1685 | 1686 | Some tests failed; see details above. 1687 | 1688 | 1689 | 1690 | Must select some files in the IDE or set test.class 1691 | Must select some method in the IDE or set test.method 1692 | 1693 | 1694 | 1695 | Some tests failed; see details above. 1696 | 1697 | 1698 | 1703 | 1704 | Must select one file in the IDE or set test.class 1705 | 1706 | 1707 | 1708 | Must select one file in the IDE or set test.class 1709 | Must select some method in the IDE or set test.method 1710 | 1711 | 1712 | 1713 | 1714 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1722 | 1727 | 1728 | Must select one file in the IDE or set applet.url 1729 | 1730 | 1731 | 1732 | 1733 | 1734 | 1735 | 1740 | 1741 | Must select one file in the IDE or set applet.url 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1764 | 1765 | 1766 | 1767 | 1768 | 1769 | 1770 | 1771 | 1772 | 1773 | 1774 | 1775 | 1776 | 1777 | 1778 | 1779 | 1780 | 1781 | 1782 | 1783 | 1784 | 1785 | 1786 | 1787 | 1788 | 1789 | 1790 | 1791 | 1792 | 1793 | 1794 | 1795 | 1796 | 1797 | 1798 | 1799 | 1800 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=439398ba 2 | build.xml.script.CRC32=3374ecd6 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.102.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=439398ba 7 | nbproject/build-impl.xml.script.CRC32=3b65b13e 8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.102.0.48 9 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=swing-ui-component 7 | application.vendor=RAVEN 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.modulepath=\ 23 | ${run.modulepath} 24 | debug.test.classpath=\ 25 | ${run.test.classpath} 26 | debug.test.modulepath=\ 27 | ${run.test.modulepath} 28 | # Files in build.classes.dir which should be excluded from distribution jar 29 | dist.archive.excludes= 30 | # This directory is removed when the project is cleaned: 31 | dist.dir=dist 32 | dist.jar=${dist.dir}/swing-ui-component.jar 33 | dist.javadoc.dir=${dist.dir}/javadoc 34 | dist.jlink.dir=${dist.dir}/jlink 35 | dist.jlink.output=${dist.jlink.dir}/swing-ui-component 36 | endorsed.classpath= 37 | excludes= 38 | file.reference.TimingFramework-0.55.jar=TimingFramework-0.55.jar 39 | includes=** 40 | jar.compress=false 41 | javac.classpath=\ 42 | ${file.reference.TimingFramework-0.55.jar} 43 | # Space-separated list of extra javac options 44 | javac.compilerargs= 45 | javac.deprecation=false 46 | javac.external.vm=true 47 | javac.modulepath= 48 | javac.processormodulepath= 49 | javac.processorpath=\ 50 | ${javac.classpath} 51 | javac.source=1.8 52 | javac.target=1.8 53 | javac.test.classpath=\ 54 | ${javac.classpath}:\ 55 | ${build.classes.dir} 56 | javac.test.modulepath=\ 57 | ${javac.modulepath} 58 | javac.test.processorpath=\ 59 | ${javac.test.classpath} 60 | javadoc.additionalparam= 61 | javadoc.author=false 62 | javadoc.encoding=${source.encoding} 63 | javadoc.html5=false 64 | javadoc.noindex=false 65 | javadoc.nonavbar=false 66 | javadoc.notree=false 67 | javadoc.private=false 68 | javadoc.splitindex=true 69 | javadoc.use=true 70 | javadoc.version=false 71 | javadoc.windowtitle= 72 | # The jlink additional root modules to resolve 73 | jlink.additionalmodules= 74 | # The jlink additional command line parameters 75 | jlink.additionalparam= 76 | jlink.launcher=true 77 | jlink.launcher.name=swing-ui-component 78 | main.class=test.Test_TextField 79 | manifest.file=manifest.mf 80 | meta.inf.dir=${src.dir}/META-INF 81 | mkdist.disabled=false 82 | platform.active=JDK_1.8 83 | run.classpath=\ 84 | ${javac.classpath}:\ 85 | ${build.classes.dir} 86 | # Space-separated list of JVM arguments used when running the project. 87 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 88 | # To set system properties for unit tests define test-sys-prop.name=value: 89 | run.jvmargs= 90 | run.modulepath=\ 91 | ${javac.modulepath} 92 | run.test.classpath=\ 93 | ${javac.test.classpath}:\ 94 | ${build.test.classes.dir} 95 | run.test.modulepath=\ 96 | ${javac.test.modulepath} 97 | source.encoding=UTF-8 98 | src.dir=src 99 | test.src.dir=test 100 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | swing-ui-component 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/button/Button.java: -------------------------------------------------------------------------------- 1 | package button; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Graphics2D; 6 | import java.awt.Insets; 7 | import java.awt.RenderingHints; 8 | import java.awt.geom.Area; 9 | import java.awt.geom.RoundRectangle2D; 10 | import java.awt.image.BufferedImage; 11 | import javax.swing.JButton; 12 | import javax.swing.border.EmptyBorder; 13 | import swing.shadow.ShadowRenderer; 14 | import swing.shadow.util.RippleEffect; 15 | 16 | public class Button extends JButton { 17 | 18 | public int getRound() { 19 | return round; 20 | } 21 | 22 | public void setRound(int round) { 23 | this.round = round; 24 | createImageShadow(); 25 | repaint(); 26 | } 27 | 28 | public Color getShadowColor() { 29 | return shadowColor; 30 | } 31 | 32 | public void setShadowColor(Color shadowColor) { 33 | this.shadowColor = shadowColor; 34 | createImageShadow(); 35 | repaint(); 36 | } 37 | 38 | public void setRippleColor(Color color) { 39 | rippleEffect.setRippleColor(color); 40 | } 41 | 42 | public Color getRippleColor() { 43 | return rippleEffect.getRippleColor(); 44 | } 45 | 46 | private int round = 10; 47 | private Color shadowColor = new Color(170, 170, 170); 48 | private BufferedImage imageShadow; 49 | private final Insets shadowSize = new Insets(2, 5, 8, 5); 50 | private final RippleEffect rippleEffect = new RippleEffect(this); 51 | 52 | public Button() { 53 | setBorder(new EmptyBorder(10, 12, 15, 12)); 54 | setContentAreaFilled(false); 55 | setBackground(new Color(255, 255, 255)); 56 | setForeground(new Color(80, 80, 80)); 57 | rippleEffect.setRippleColor(new Color(220, 220, 220)); 58 | } 59 | 60 | @Override 61 | protected void paintComponent(Graphics grphcs) { 62 | Graphics2D g2 = (Graphics2D) grphcs.create(); 63 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 64 | double width = getWidth() - (shadowSize.left + shadowSize.right); 65 | double height = getHeight() - (shadowSize.top + shadowSize.bottom); 66 | double x = shadowSize.left; 67 | double y = shadowSize.top; 68 | // Create Shadow Image 69 | g2.drawImage(imageShadow, 0, 0, null); 70 | // Create Background Color 71 | g2.setColor(getBackground()); 72 | Area area = new Area(new RoundRectangle2D.Double(x, y, width, height, round, round)); 73 | g2.fill(area); 74 | rippleEffect.reder(grphcs, area); 75 | g2.dispose(); 76 | super.paintComponent(grphcs); 77 | } 78 | 79 | @Override 80 | public void setBounds(int x, int y, int width, int height) { 81 | super.setBounds(x, y, width, height); 82 | createImageShadow(); 83 | } 84 | 85 | private void createImageShadow() { 86 | int height = getHeight(); 87 | int width = getWidth(); 88 | if (width > 0 && height > 0) { 89 | imageShadow = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 90 | Graphics2D g2 = imageShadow.createGraphics(); 91 | BufferedImage img = createShadow(); 92 | if (img != null) { 93 | g2.drawImage(createShadow(), 0, 0, null); 94 | } 95 | g2.dispose(); 96 | } 97 | } 98 | 99 | private BufferedImage createShadow() { 100 | int width = getWidth() - (shadowSize.left + shadowSize.right); 101 | int height = getHeight() - (shadowSize.top + shadowSize.bottom); 102 | if (width > 0 && height > 0) { 103 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 104 | Graphics2D g2 = img.createGraphics(); 105 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 106 | g2.fill(new RoundRectangle2D.Double(0, 0, width, height, round, round)); 107 | g2.dispose(); 108 | return new ShadowRenderer(5, 0.3f, shadowColor).createShadow(img); 109 | } else { 110 | return null; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/passwordfield/PasswordField.java: -------------------------------------------------------------------------------- 1 | package passwordfield; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Graphics2D; 6 | import java.awt.Insets; 7 | import java.awt.RenderingHints; 8 | import java.awt.geom.Area; 9 | import java.awt.geom.RoundRectangle2D; 10 | import java.awt.image.BufferedImage; 11 | import javax.swing.JPasswordField; 12 | import javax.swing.border.EmptyBorder; 13 | import javax.swing.plaf.basic.BasicPasswordFieldUI; 14 | import swing.shadow.ShadowRenderer; 15 | 16 | public class PasswordField extends JPasswordField { 17 | 18 | public int getRound() { 19 | return round; 20 | } 21 | 22 | public void setRound(int round) { 23 | this.round = round; 24 | createImageShadow(); 25 | repaint(); 26 | } 27 | 28 | public Color getShadowColor() { 29 | return shadowColor; 30 | } 31 | 32 | public void setShadowColor(Color shadowColor) { 33 | this.shadowColor = shadowColor; 34 | createImageShadow(); 35 | repaint(); 36 | } 37 | 38 | private int round = 10; 39 | private Color shadowColor = new Color(170, 170, 170); 40 | private BufferedImage imageShadow; 41 | private final Insets shadowSize = new Insets(2, 5, 8, 5); 42 | 43 | public PasswordField() { 44 | setUI(new TextUI()); 45 | setOpaque(false); 46 | setForeground(new Color(80, 80, 80)); 47 | setSelectedTextColor(new Color(255, 255, 255)); 48 | setSelectionColor(new Color(133, 209, 255)); 49 | setBorder(new EmptyBorder(10, 12, 15, 12)); 50 | setBackground(new Color(255, 255, 255)); 51 | } 52 | 53 | @Override 54 | protected void paintComponent(Graphics grphcs) { 55 | Graphics2D g2 = (Graphics2D) grphcs.create(); 56 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 57 | double width = getWidth() - (shadowSize.left + shadowSize.right); 58 | double height = getHeight() - (shadowSize.top + shadowSize.bottom); 59 | double x = shadowSize.left; 60 | double y = shadowSize.top; 61 | // Create Shadow Image 62 | g2.drawImage(imageShadow, 0, 0, null); 63 | // Create Background Color 64 | g2.setColor(getBackground()); 65 | Area area = new Area(new RoundRectangle2D.Double(x, y, width, height, round, round)); 66 | g2.fill(area); 67 | g2.dispose(); 68 | super.paintComponent(grphcs); 69 | } 70 | 71 | @Override 72 | public void setBounds(int x, int y, int width, int height) { 73 | super.setBounds(x, y, width, height); 74 | createImageShadow(); 75 | } 76 | 77 | private void createImageShadow() { 78 | int height = getHeight(); 79 | int width = getWidth(); 80 | if (width > 0 && height > 0) { 81 | imageShadow = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 82 | Graphics2D g2 = imageShadow.createGraphics(); 83 | BufferedImage img = createShadow(); 84 | if (img != null) { 85 | g2.drawImage(createShadow(), 0, 0, null); 86 | } 87 | g2.dispose(); 88 | } 89 | } 90 | 91 | private BufferedImage createShadow() { 92 | int width = getWidth() - (shadowSize.left + shadowSize.right); 93 | int height = getHeight() - (shadowSize.top + shadowSize.bottom); 94 | if (width > 0 && height > 0) { 95 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 96 | Graphics2D g2 = img.createGraphics(); 97 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 98 | g2.fill(new RoundRectangle2D.Double(0, 0, width, height, round, round)); 99 | g2.dispose(); 100 | return new ShadowRenderer(5, 0.3f, shadowColor).createShadow(img); 101 | } else { 102 | return null; 103 | } 104 | } 105 | 106 | private class TextUI extends BasicPasswordFieldUI { 107 | 108 | // Override this method to remove background or not paint background 109 | @Override 110 | protected void paintBackground(Graphics grphcs) { 111 | 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/swing/shadow/GraphicsUtilities.java: -------------------------------------------------------------------------------- 1 | package swing.shadow; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.awt.image.ColorModel; 5 | import java.awt.image.Raster; 6 | import java.awt.image.WritableRaster; 7 | import java.awt.GraphicsConfiguration; 8 | import java.awt.Transparency; 9 | import java.awt.Graphics; 10 | import java.awt.GraphicsEnvironment; 11 | import java.awt.Graphics2D; 12 | import java.awt.RenderingHints; 13 | import java.io.IOException; 14 | import java.net.URL; 15 | import javax.imageio.ImageIO; 16 | 17 | public class GraphicsUtilities { 18 | 19 | private GraphicsUtilities() { 20 | } 21 | 22 | // Returns the graphics configuration for the primary screen 23 | private static GraphicsConfiguration getGraphicsConfiguration() { 24 | return GraphicsEnvironment.getLocalGraphicsEnvironment(). 25 | getDefaultScreenDevice().getDefaultConfiguration(); 26 | } 27 | 28 | public static BufferedImage createColorModelCompatibleImage(BufferedImage image) { 29 | ColorModel cm = image.getColorModel(); 30 | return new BufferedImage(cm, 31 | cm.createCompatibleWritableRaster(image.getWidth(), 32 | image.getHeight()), 33 | cm.isAlphaPremultiplied(), null); 34 | } 35 | 36 | public static BufferedImage createCompatibleImage(BufferedImage image) { 37 | return createCompatibleImage(image, image.getWidth(), image.getHeight()); 38 | } 39 | 40 | public static BufferedImage createCompatibleImage(BufferedImage image, 41 | int width, int height) { 42 | return getGraphicsConfiguration().createCompatibleImage(width, height, 43 | image.getTransparency()); 44 | } 45 | 46 | public static BufferedImage createCompatibleImage(int width, int height) { 47 | return getGraphicsConfiguration().createCompatibleImage(width, height); 48 | } 49 | 50 | public static BufferedImage createCompatibleTranslucentImage(int width, 51 | int height) { 52 | return getGraphicsConfiguration().createCompatibleImage(width, height, 53 | Transparency.TRANSLUCENT); 54 | } 55 | 56 | public static BufferedImage loadCompatibleImage(URL resource) 57 | throws IOException { 58 | BufferedImage image = ImageIO.read(resource); 59 | return toCompatibleImage(image); 60 | } 61 | 62 | public static BufferedImage toCompatibleImage(BufferedImage image) { 63 | if (image.getColorModel().equals( 64 | getGraphicsConfiguration().getColorModel())) { 65 | return image; 66 | } 67 | BufferedImage compatibleImage 68 | = getGraphicsConfiguration().createCompatibleImage( 69 | image.getWidth(), image.getHeight(), 70 | image.getTransparency()); 71 | Graphics g = compatibleImage.getGraphics(); 72 | g.drawImage(image, 0, 0, null); 73 | g.dispose(); 74 | return compatibleImage; 75 | } 76 | 77 | public static BufferedImage createThumbnailFast(BufferedImage image, 78 | int newSize) { 79 | float ratio; 80 | int width = image.getWidth(); 81 | int height = image.getHeight(); 82 | if (width > height) { 83 | if (newSize >= width) { 84 | throw new IllegalArgumentException("newSize must be lower than" 85 | + " the image width"); 86 | } else if (newSize <= 0) { 87 | throw new IllegalArgumentException("newSize must" 88 | + " be greater than 0"); 89 | } 90 | ratio = (float) width / (float) height; 91 | width = newSize; 92 | height = (int) (newSize / ratio); 93 | } else { 94 | if (newSize >= height) { 95 | throw new IllegalArgumentException("newSize must be lower than" 96 | + " the image height"); 97 | } else if (newSize <= 0) { 98 | throw new IllegalArgumentException("newSize must" 99 | + " be greater than 0"); 100 | } 101 | ratio = (float) height / (float) width; 102 | height = newSize; 103 | width = (int) (newSize / ratio); 104 | } 105 | BufferedImage temp = createCompatibleImage(image, width, height); 106 | Graphics2D g2 = temp.createGraphics(); 107 | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 108 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); 109 | g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null); 110 | g2.dispose(); 111 | return temp; 112 | } 113 | 114 | public static BufferedImage createThumbnailFast(BufferedImage image, 115 | int newWidth, int newHeight) { 116 | if (newWidth >= image.getWidth() 117 | || newHeight >= image.getHeight()) { 118 | throw new IllegalArgumentException("newWidth and newHeight cannot" 119 | + " be greater than the image" 120 | + " dimensions"); 121 | } else if (newWidth <= 0 || newHeight <= 0) { 122 | throw new IllegalArgumentException("newWidth and newHeight must" 123 | + " be greater than 0"); 124 | } 125 | BufferedImage temp = createCompatibleImage(image, newWidth, newHeight); 126 | Graphics2D g2 = temp.createGraphics(); 127 | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 128 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); 129 | g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null); 130 | g2.dispose(); 131 | return temp; 132 | } 133 | 134 | public static BufferedImage createThumbnail(BufferedImage image, 135 | int newSize) { 136 | int width = image.getWidth(); 137 | int height = image.getHeight(); 138 | boolean isWidthGreater = width > height; 139 | if (isWidthGreater) { 140 | if (newSize >= width) { 141 | throw new IllegalArgumentException("newSize must be lower than" 142 | + " the image width"); 143 | } 144 | } else if (newSize >= height) { 145 | throw new IllegalArgumentException("newSize must be lower than" 146 | + " the image height"); 147 | } 148 | if (newSize <= 0) { 149 | throw new IllegalArgumentException("newSize must" 150 | + " be greater than 0"); 151 | } 152 | float ratioWH = (float) width / (float) height; 153 | float ratioHW = (float) height / (float) width; 154 | BufferedImage thumb = image; 155 | do { 156 | if (isWidthGreater) { 157 | width /= 2; 158 | if (width < newSize) { 159 | width = newSize; 160 | } 161 | height = (int) (width / ratioWH); 162 | } else { 163 | height /= 2; 164 | if (height < newSize) { 165 | height = newSize; 166 | } 167 | width = (int) (height / ratioHW); 168 | } 169 | BufferedImage temp = createCompatibleImage(image, width, height); 170 | Graphics2D g2 = temp.createGraphics(); 171 | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 172 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); 173 | g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null); 174 | g2.dispose(); 175 | thumb = temp; 176 | } while (newSize != (isWidthGreater ? width : height)); 177 | return thumb; 178 | } 179 | 180 | public static BufferedImage createThumbnail(BufferedImage image, 181 | int newWidth, int newHeight) { 182 | int width = image.getWidth(); 183 | int height = image.getHeight(); 184 | 185 | if (newWidth >= width || newHeight >= height) { 186 | throw new IllegalArgumentException("newWidth and newHeight cannot" 187 | + " be greater than the image" 188 | + " dimensions"); 189 | } else if (newWidth <= 0 || newHeight <= 0) { 190 | throw new IllegalArgumentException("newWidth and newHeight must" 191 | + " be greater than 0"); 192 | } 193 | BufferedImage thumb = image; 194 | do { 195 | if (width > newWidth) { 196 | width /= 2; 197 | if (width < newWidth) { 198 | width = newWidth; 199 | } 200 | } 201 | if (height > newHeight) { 202 | height /= 2; 203 | if (height < newHeight) { 204 | height = newHeight; 205 | } 206 | } 207 | BufferedImage temp = createCompatibleImage(image, width, height); 208 | Graphics2D g2 = temp.createGraphics(); 209 | g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 210 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); 211 | g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null); 212 | g2.dispose(); 213 | thumb = temp; 214 | } while (width != newWidth || height != newHeight); 215 | return thumb; 216 | } 217 | 218 | public static int[] getPixels(BufferedImage img, 219 | int x, int y, int w, int h, int[] pixels) { 220 | if (w == 0 || h == 0) { 221 | return new int[0]; 222 | } 223 | if (pixels == null) { 224 | pixels = new int[w * h]; 225 | } else if (pixels.length < w * h) { 226 | throw new IllegalArgumentException("pixels array must have a length" 227 | + " >= w*h"); 228 | } 229 | int imageType = img.getType(); 230 | if (imageType == BufferedImage.TYPE_INT_ARGB 231 | || imageType == BufferedImage.TYPE_INT_RGB) { 232 | Raster raster = img.getRaster(); 233 | return (int[]) raster.getDataElements(x, y, w, h, pixels); 234 | } 235 | // Unmanages the image 236 | return img.getRGB(x, y, w, h, pixels, 0, w); 237 | } 238 | 239 | public static void setPixels(BufferedImage img, 240 | int x, int y, int w, int h, int[] pixels) { 241 | if (pixels == null || w == 0 || h == 0) { 242 | return; 243 | } else if (pixels.length < w * h) { 244 | throw new IllegalArgumentException("pixels array must have a length" 245 | + " >= w*h"); 246 | } 247 | 248 | int imageType = img.getType(); 249 | if (imageType == BufferedImage.TYPE_INT_ARGB 250 | || imageType == BufferedImage.TYPE_INT_RGB) { 251 | WritableRaster raster = img.getRaster(); 252 | raster.setDataElements(x, y, w, h, pixels); 253 | } else { 254 | // Unmanages the image 255 | img.setRGB(x, y, w, h, pixels, 0, w); 256 | } 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /src/swing/shadow/ShadowRenderer.java: -------------------------------------------------------------------------------- 1 | package swing.shadow; 2 | 3 | import java.awt.Color; 4 | import java.awt.image.BufferedImage; 5 | 6 | public class ShadowRenderer { 7 | 8 | private int size = 5; 9 | private float opacity = 0.5f; 10 | private Color color = Color.BLACK; 11 | 12 | public ShadowRenderer() { 13 | this(5, 0.5f, Color.BLACK); 14 | } 15 | 16 | public ShadowRenderer(final int size, final float opacity, final Color color) { 17 | this.size = size; 18 | this.opacity = opacity; 19 | this.color = color; 20 | } 21 | 22 | public Color getColor() { 23 | return color; 24 | } 25 | 26 | public float getOpacity() { 27 | return opacity; 28 | } 29 | 30 | public int getSize() { 31 | return size; 32 | } 33 | 34 | public BufferedImage createShadow(final BufferedImage image) { 35 | int shadowSize = size * 2; 36 | int srcWidth = image.getWidth(); 37 | int srcHeight = image.getHeight(); 38 | int dstWidth = srcWidth + shadowSize; 39 | int dstHeight = srcHeight + shadowSize; 40 | int left = size; 41 | int right = shadowSize - left; 42 | int yStop = dstHeight - right; 43 | int shadowRgb = color.getRGB() & 0x00FFFFFF; 44 | int[] aHistory = new int[shadowSize]; 45 | int historyIdx; 46 | int aSum; 47 | BufferedImage dst = new BufferedImage(dstWidth, dstHeight, 48 | BufferedImage.TYPE_INT_ARGB); 49 | int[] dstBuffer = new int[dstWidth * dstHeight]; 50 | int[] srcBuffer = new int[srcWidth * srcHeight]; 51 | GraphicsUtilities.getPixels(image, 0, 0, srcWidth, srcHeight, srcBuffer); 52 | int lastPixelOffset = right * dstWidth; 53 | float hSumDivider = 1.0f / shadowSize; 54 | float vSumDivider = opacity / shadowSize; 55 | int[] hSumLookup = new int[256 * shadowSize]; 56 | for (int i = 0; i < hSumLookup.length; i++) { 57 | hSumLookup[i] = (int) (i * hSumDivider); 58 | } 59 | int[] vSumLookup = new int[256 * shadowSize]; 60 | for (int i = 0; i < vSumLookup.length; i++) { 61 | vSumLookup[i] = (int) (i * vSumDivider); 62 | } 63 | int srcOffset; 64 | for (int srcY = 0, dstOffset = left * dstWidth; srcY < srcHeight; srcY++) { 65 | for (historyIdx = 0; historyIdx < shadowSize;) { 66 | aHistory[historyIdx++] = 0; 67 | } 68 | aSum = 0; 69 | historyIdx = 0; 70 | srcOffset = srcY * srcWidth; 71 | for (int srcX = 0; srcX < srcWidth; srcX++) { 72 | int a = hSumLookup[aSum]; 73 | dstBuffer[dstOffset++] = a << 24; 74 | aSum -= aHistory[historyIdx]; 75 | a = srcBuffer[srcOffset + srcX] >>> 24; 76 | aHistory[historyIdx] = a; 77 | aSum += a; 78 | if (++historyIdx >= shadowSize) { 79 | historyIdx -= shadowSize; 80 | } 81 | } 82 | for (int i = 0; i < shadowSize; i++) { 83 | int a = hSumLookup[aSum]; 84 | dstBuffer[dstOffset++] = a << 24; 85 | aSum -= aHistory[historyIdx]; 86 | if (++historyIdx >= shadowSize) { 87 | historyIdx -= shadowSize; 88 | } 89 | } 90 | } 91 | 92 | for (int x = 0, bufferOffset = 0; x < dstWidth; x++, bufferOffset = x) { 93 | aSum = 0; 94 | for (historyIdx = 0; historyIdx < left;) { 95 | aHistory[historyIdx++] = 0; 96 | } 97 | for (int y = 0; y < right; y++, bufferOffset += dstWidth) { 98 | int a = dstBuffer[bufferOffset] >>> 24; 99 | aHistory[historyIdx++] = a; 100 | aSum += a; 101 | } 102 | bufferOffset = x; 103 | historyIdx = 0; 104 | for (int y = 0; y < yStop; y++, bufferOffset += dstWidth) { 105 | int a = vSumLookup[aSum]; 106 | dstBuffer[bufferOffset] = a << 24 | shadowRgb; 107 | aSum -= aHistory[historyIdx]; 108 | a = dstBuffer[bufferOffset + lastPixelOffset] >>> 24; 109 | aHistory[historyIdx] = a; 110 | aSum += a; 111 | if (++historyIdx >= shadowSize) { 112 | historyIdx -= shadowSize; 113 | } 114 | } 115 | for (int y = yStop; y < dstHeight; y++, bufferOffset += dstWidth) { 116 | int a = vSumLookup[aSum]; 117 | dstBuffer[bufferOffset] = a << 24 | shadowRgb; 118 | aSum -= aHistory[historyIdx]; 119 | if (++historyIdx >= shadowSize) { 120 | historyIdx -= shadowSize; 121 | } 122 | } 123 | } 124 | GraphicsUtilities.setPixels(dst, 0, 0, dstWidth, dstHeight, dstBuffer); 125 | return dst; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/swing/shadow/util/RippleEffect.java: -------------------------------------------------------------------------------- 1 | package swing.shadow.util; 2 | 3 | import java.awt.AlphaComposite; 4 | import java.awt.Color; 5 | import java.awt.Component; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.Point; 9 | import java.awt.RenderingHints; 10 | import java.awt.Shape; 11 | import java.awt.event.MouseAdapter; 12 | import java.awt.event.MouseEvent; 13 | import java.awt.geom.Area; 14 | import java.awt.geom.Ellipse2D; 15 | import java.awt.geom.Rectangle2D; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import javax.swing.SwingUtilities; 19 | import org.jdesktop.animation.timing.Animator; 20 | import org.jdesktop.animation.timing.TimingTargetAdapter; 21 | 22 | public class RippleEffect { 23 | 24 | private final Component component; 25 | private Color rippleColor = new Color(255, 255, 255); 26 | private List effects; 27 | 28 | public RippleEffect(Component component) { 29 | this.component = component; 30 | init(); 31 | } 32 | 33 | private void init() { 34 | effects = new ArrayList<>(); 35 | component.addMouseListener(new MouseAdapter() { 36 | @Override 37 | public void mousePressed(MouseEvent e) { 38 | if (SwingUtilities.isLeftMouseButton(e)) { 39 | addEffect(e.getPoint()); 40 | } 41 | } 42 | }); 43 | } 44 | 45 | public void addEffect(Point location) { 46 | effects.add(new Effect(component, location)); 47 | } 48 | 49 | public void reder(Graphics g, Shape contain) { 50 | Graphics2D g2 = (Graphics2D) g.create(); 51 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 52 | for (int i = 0; i < effects.size(); i++) { 53 | Effect effect = effects.get(i); 54 | if (effect != null) { 55 | effect.render(g2, contain); 56 | } 57 | } 58 | } 59 | 60 | private class Effect { 61 | 62 | private final Component component; 63 | private final Point location; 64 | private Animator animator; 65 | private float animate; 66 | 67 | public Effect(Component component, Point location) { 68 | this.component = component; 69 | this.location = location; 70 | init(); 71 | } 72 | 73 | private void init() { 74 | animator = new Animator(500, new TimingTargetAdapter() { 75 | @Override 76 | public void timingEvent(float fraction) { 77 | animate = fraction; 78 | component.repaint(); 79 | } 80 | 81 | @Override 82 | public void end() { 83 | effects.remove(Effect.this); 84 | } 85 | }); 86 | animator.setResolution(5); 87 | animator.setDeceleration(.5f); 88 | animator.start(); 89 | } 90 | 91 | public void render(Graphics2D g2, Shape contain) { 92 | Area area = new Area(contain); 93 | area.intersect(new Area(getShape(getSize(contain.getBounds2D())))); 94 | g2.setColor(rippleColor); 95 | float alpha = 0.3f; 96 | if (animate >= 0.7f) { 97 | double t = animate - 0.7f; 98 | alpha = (float) (alpha - (alpha * (t / 0.3f))); 99 | } 100 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); 101 | g2.fill(area); 102 | } 103 | 104 | private Shape getShape(double size) { 105 | double s = size * animate; 106 | double x = location.getX(); 107 | double y = location.getY(); 108 | Shape shape = new Ellipse2D.Double(x - s, y - s, s * 2, s * 2); 109 | return shape; 110 | } 111 | 112 | private double getSize(Rectangle2D rec) { 113 | double size; 114 | if (rec.getWidth() > rec.getHeight()) { 115 | if (location.getX() < rec.getWidth() / 2) { 116 | size = rec.getWidth() - location.getX(); 117 | } else { 118 | size = location.getX(); 119 | } 120 | } else { 121 | if (location.getY() < rec.getHeight() / 2) { 122 | size = rec.getHeight() - location.getY(); 123 | } else { 124 | size = location.getY(); 125 | } 126 | } 127 | return size + (size * 0.1f); 128 | } 129 | } 130 | 131 | public void setRippleColor(Color rippleColor) { 132 | this.rippleColor = rippleColor; 133 | } 134 | 135 | public Color getRippleColor() { 136 | return rippleColor; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/test/Test.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 |
187 | -------------------------------------------------------------------------------- /src/test/Test.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | /** 4 | * 5 | * @author raven 6 | */ 7 | public class Test extends javax.swing.JFrame { 8 | 9 | /** 10 | * Creates new form NewJFrame 11 | */ 12 | public Test() { 13 | initComponents(); 14 | 15 | } 16 | 17 | /** 18 | * This method is called from within the constructor to initialize the form. 19 | * WARNING: Do NOT modify this code. The content of this method is always 20 | * regenerated by the Form Editor. 21 | */ 22 | @SuppressWarnings("unchecked") 23 | // //GEN-BEGIN:initComponents 24 | private void initComponents() { 25 | 26 | jPanel1 = new javax.swing.JPanel(); 27 | cmd = new button.Button(); 28 | cmd1 = new button.Button(); 29 | cmd2 = new button.Button(); 30 | cmd3 = new button.Button(); 31 | cmd4 = new button.Button(); 32 | cmd5 = new button.Button(); 33 | 34 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 35 | 36 | jPanel1.setBackground(new java.awt.Color(246, 246, 246)); 37 | 38 | cmd.setText("JButton Custom"); 39 | cmd.addActionListener(new java.awt.event.ActionListener() { 40 | public void actionPerformed(java.awt.event.ActionEvent evt) { 41 | cmdActionPerformed(evt); 42 | } 43 | }); 44 | 45 | cmd1.setBackground(new java.awt.Color(253, 83, 83)); 46 | cmd1.setForeground(new java.awt.Color(245, 245, 245)); 47 | cmd1.setText("JButton Custom"); 48 | cmd1.setRippleColor(new java.awt.Color(255, 255, 255)); 49 | cmd1.setShadowColor(new java.awt.Color(253, 83, 83)); 50 | cmd1.addActionListener(new java.awt.event.ActionListener() { 51 | public void actionPerformed(java.awt.event.ActionEvent evt) { 52 | cmd1ActionPerformed(evt); 53 | } 54 | }); 55 | 56 | cmd2.setBackground(new java.awt.Color(29, 162, 253)); 57 | cmd2.setForeground(new java.awt.Color(245, 245, 245)); 58 | cmd2.setText("JButton Custom"); 59 | cmd2.setRippleColor(new java.awt.Color(255, 255, 255)); 60 | cmd2.setShadowColor(new java.awt.Color(29, 162, 253)); 61 | cmd2.addActionListener(new java.awt.event.ActionListener() { 62 | public void actionPerformed(java.awt.event.ActionEvent evt) { 63 | cmd2ActionPerformed(evt); 64 | } 65 | }); 66 | 67 | cmd3.setBackground(new java.awt.Color(30, 180, 114)); 68 | cmd3.setForeground(new java.awt.Color(245, 245, 245)); 69 | cmd3.setText("JButton Custom"); 70 | cmd3.setRippleColor(new java.awt.Color(255, 255, 255)); 71 | cmd3.setShadowColor(new java.awt.Color(30, 180, 114)); 72 | cmd3.addActionListener(new java.awt.event.ActionListener() { 73 | public void actionPerformed(java.awt.event.ActionEvent evt) { 74 | cmd3ActionPerformed(evt); 75 | } 76 | }); 77 | 78 | cmd4.setBackground(new java.awt.Color(103, 103, 103)); 79 | cmd4.setForeground(new java.awt.Color(245, 245, 245)); 80 | cmd4.setText("JButton Custom"); 81 | cmd4.addActionListener(new java.awt.event.ActionListener() { 82 | public void actionPerformed(java.awt.event.ActionEvent evt) { 83 | cmd4ActionPerformed(evt); 84 | } 85 | }); 86 | 87 | cmd5.setBackground(new java.awt.Color(246, 159, 50)); 88 | cmd5.setForeground(new java.awt.Color(245, 245, 245)); 89 | cmd5.setText("JButton Custom"); 90 | cmd5.setRippleColor(new java.awt.Color(255, 255, 255)); 91 | cmd5.setShadowColor(new java.awt.Color(246, 159, 50)); 92 | cmd5.addActionListener(new java.awt.event.ActionListener() { 93 | public void actionPerformed(java.awt.event.ActionEvent evt) { 94 | cmd5ActionPerformed(evt); 95 | } 96 | }); 97 | 98 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 99 | jPanel1.setLayout(jPanel1Layout); 100 | jPanel1Layout.setHorizontalGroup( 101 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 102 | .addGroup(jPanel1Layout.createSequentialGroup() 103 | .addGap(250, 250, 250) 104 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 105 | .addComponent(cmd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 106 | .addComponent(cmd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 107 | .addComponent(cmd3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 108 | .addComponent(cmd4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 109 | .addComponent(cmd5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 110 | .addComponent(cmd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 111 | .addGap(250, 250, 250)) 112 | ); 113 | jPanel1Layout.setVerticalGroup( 114 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 115 | .addGroup(jPanel1Layout.createSequentialGroup() 116 | .addGap(80, 80, 80) 117 | .addComponent(cmd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 118 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 119 | .addComponent(cmd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 120 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 121 | .addComponent(cmd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 122 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 123 | .addComponent(cmd3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 125 | .addComponent(cmd4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 126 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 127 | .addComponent(cmd5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 128 | .addContainerGap(102, Short.MAX_VALUE)) 129 | ); 130 | 131 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 132 | getContentPane().setLayout(layout); 133 | layout.setHorizontalGroup( 134 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 135 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 136 | ); 137 | layout.setVerticalGroup( 138 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 139 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 140 | ); 141 | 142 | pack(); 143 | setLocationRelativeTo(null); 144 | }// //GEN-END:initComponents 145 | 146 | private void cmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdActionPerformed 147 | // TODO add your handling code here: 148 | }//GEN-LAST:event_cmdActionPerformed 149 | 150 | private void cmd1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd1ActionPerformed 151 | // TODO add your handling code here: 152 | }//GEN-LAST:event_cmd1ActionPerformed 153 | 154 | private void cmd2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd2ActionPerformed 155 | // TODO add your handling code here: 156 | }//GEN-LAST:event_cmd2ActionPerformed 157 | 158 | private void cmd3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd3ActionPerformed 159 | // TODO add your handling code here: 160 | }//GEN-LAST:event_cmd3ActionPerformed 161 | 162 | private void cmd4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd4ActionPerformed 163 | // TODO add your handling code here: 164 | }//GEN-LAST:event_cmd4ActionPerformed 165 | 166 | private void cmd5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmd5ActionPerformed 167 | // TODO add your handling code here: 168 | }//GEN-LAST:event_cmd5ActionPerformed 169 | 170 | /** 171 | * @param args the command line arguments 172 | */ 173 | public static void main(String args[]) { 174 | /* Set the Nimbus look and feel */ 175 | // 176 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 177 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 178 | */ 179 | try { 180 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 181 | if ("Nimbus".equals(info.getName())) { 182 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 183 | break; 184 | } 185 | } 186 | } catch (ClassNotFoundException ex) { 187 | java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 188 | } catch (InstantiationException ex) { 189 | java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 190 | } catch (IllegalAccessException ex) { 191 | java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 192 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 193 | java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 194 | } 195 | // 196 | 197 | /* Create and display the form */ 198 | java.awt.EventQueue.invokeLater(new Runnable() { 199 | public void run() { 200 | new Test().setVisible(true); 201 | } 202 | }); 203 | } 204 | 205 | // Variables declaration - do not modify//GEN-BEGIN:variables 206 | private button.Button cmd; 207 | private button.Button cmd1; 208 | private button.Button cmd2; 209 | private button.Button cmd3; 210 | private button.Button cmd4; 211 | private button.Button cmd5; 212 | private javax.swing.JPanel jPanel1; 213 | // End of variables declaration//GEN-END:variables 214 | } 215 | -------------------------------------------------------------------------------- /src/test/Test_TextField.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |
116 | -------------------------------------------------------------------------------- /src/test/Test_TextField.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | /** 4 | * 5 | * @author RAVEN 6 | */ 7 | public class Test_TextField extends javax.swing.JFrame { 8 | 9 | /** 10 | * Creates new form Test_TextField 11 | */ 12 | public Test_TextField() { 13 | initComponents(); 14 | } 15 | 16 | /** 17 | * This method is called from within the constructor to initialize the form. 18 | * WARNING: Do NOT modify this code. The content of this method is always 19 | * regenerated by the Form Editor. 20 | */ 21 | @SuppressWarnings("unchecked") 22 | // //GEN-BEGIN:initComponents 23 | private void initComponents() { 24 | 25 | jPanel1 = new javax.swing.JPanel(); 26 | textField1 = new textfield.TextField(); 27 | textField2 = new textfield.TextField(); 28 | passwordField1 = new passwordfield.PasswordField(); 29 | passwordField2 = new passwordfield.PasswordField(); 30 | passwordField3 = new passwordfield.PasswordField(); 31 | 32 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 33 | 34 | jPanel1.setBackground(new java.awt.Color(246, 246, 246)); 35 | 36 | textField1.setText("textField1"); 37 | 38 | textField2.setText("textField1"); 39 | textField2.setShadowColor(new java.awt.Color(219, 76, 76)); 40 | 41 | passwordField1.setText("passwordField1"); 42 | 43 | passwordField2.setText("passwordField1"); 44 | passwordField2.setShadowColor(new java.awt.Color(51, 51, 255)); 45 | 46 | passwordField3.setText("passwordField1"); 47 | passwordField3.setShadowColor(new java.awt.Color(35, 199, 2)); 48 | 49 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 50 | jPanel1.setLayout(jPanel1Layout); 51 | jPanel1Layout.setHorizontalGroup( 52 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 53 | .addGroup(jPanel1Layout.createSequentialGroup() 54 | .addGap(181, 181, 181) 55 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 56 | .addComponent(textField1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 57 | .addComponent(textField2, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE) 58 | .addComponent(passwordField1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 59 | .addComponent(passwordField2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 60 | .addComponent(passwordField3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 61 | .addContainerGap(194, Short.MAX_VALUE)) 62 | ); 63 | jPanel1Layout.setVerticalGroup( 64 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 65 | .addGroup(jPanel1Layout.createSequentialGroup() 66 | .addGap(90, 90, 90) 67 | .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 68 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 69 | .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 70 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 71 | .addComponent(passwordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 72 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 73 | .addComponent(passwordField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 74 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 75 | .addComponent(passwordField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 76 | .addContainerGap(164, Short.MAX_VALUE)) 77 | ); 78 | 79 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 80 | getContentPane().setLayout(layout); 81 | layout.setHorizontalGroup( 82 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 83 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 84 | ); 85 | layout.setVerticalGroup( 86 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 87 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 88 | ); 89 | 90 | pack(); 91 | setLocationRelativeTo(null); 92 | }// //GEN-END:initComponents 93 | 94 | /** 95 | * @param args the command line arguments 96 | */ 97 | public static void main(String args[]) { 98 | /* Set the Nimbus look and feel */ 99 | // 100 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 101 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 102 | */ 103 | try { 104 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 105 | if ("Nimbus".equals(info.getName())) { 106 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 107 | break; 108 | } 109 | } 110 | } catch (ClassNotFoundException ex) { 111 | java.util.logging.Logger.getLogger(Test_TextField.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 112 | } catch (InstantiationException ex) { 113 | java.util.logging.Logger.getLogger(Test_TextField.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 114 | } catch (IllegalAccessException ex) { 115 | java.util.logging.Logger.getLogger(Test_TextField.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 116 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 117 | java.util.logging.Logger.getLogger(Test_TextField.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 118 | } 119 | // 120 | 121 | /* Create and display the form */ 122 | java.awt.EventQueue.invokeLater(new Runnable() { 123 | public void run() { 124 | new Test_TextField().setVisible(true); 125 | } 126 | }); 127 | } 128 | 129 | // Variables declaration - do not modify//GEN-BEGIN:variables 130 | private javax.swing.JPanel jPanel1; 131 | private passwordfield.PasswordField passwordField1; 132 | private passwordfield.PasswordField passwordField2; 133 | private passwordfield.PasswordField passwordField3; 134 | private textfield.TextField textField1; 135 | private textfield.TextField textField2; 136 | // End of variables declaration//GEN-END:variables 137 | } 138 | -------------------------------------------------------------------------------- /src/textfield/TextField.java: -------------------------------------------------------------------------------- 1 | package textfield; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Graphics2D; 6 | import java.awt.Insets; 7 | import java.awt.RenderingHints; 8 | import java.awt.geom.Area; 9 | import java.awt.geom.RoundRectangle2D; 10 | import java.awt.image.BufferedImage; 11 | import javax.swing.JTextField; 12 | import javax.swing.border.EmptyBorder; 13 | import javax.swing.plaf.basic.BasicTextFieldUI; 14 | import swing.shadow.ShadowRenderer; 15 | 16 | public class TextField extends JTextField { 17 | 18 | public int getRound() { 19 | return round; 20 | } 21 | 22 | public void setRound(int round) { 23 | this.round = round; 24 | createImageShadow(); 25 | repaint(); 26 | } 27 | 28 | public Color getShadowColor() { 29 | return shadowColor; 30 | } 31 | 32 | public void setShadowColor(Color shadowColor) { 33 | this.shadowColor = shadowColor; 34 | createImageShadow(); 35 | repaint(); 36 | } 37 | 38 | private int round = 10; 39 | private Color shadowColor = new Color(170, 170, 170); 40 | private BufferedImage imageShadow; 41 | private final Insets shadowSize = new Insets(2, 5, 8, 5); 42 | 43 | public TextField() { 44 | setUI(new TextUI()); 45 | setOpaque(false); 46 | setForeground(new Color(80, 80, 80)); 47 | setSelectedTextColor(new Color(255, 255, 255)); 48 | setSelectionColor(new Color(133, 209, 255)); 49 | setBorder(new EmptyBorder(10, 12, 15, 12)); 50 | setBackground(new Color(255, 255, 255)); 51 | } 52 | 53 | @Override 54 | protected void paintComponent(Graphics grphcs) { 55 | Graphics2D g2 = (Graphics2D) grphcs.create(); 56 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 57 | double width = getWidth() - (shadowSize.left + shadowSize.right); 58 | double height = getHeight() - (shadowSize.top + shadowSize.bottom); 59 | double x = shadowSize.left; 60 | double y = shadowSize.top; 61 | // Create Shadow Image 62 | g2.drawImage(imageShadow, 0, 0, null); 63 | // Create Background Color 64 | g2.setColor(getBackground()); 65 | Area area = new Area(new RoundRectangle2D.Double(x, y, width, height, round, round)); 66 | g2.fill(area); 67 | g2.dispose(); 68 | super.paintComponent(grphcs); 69 | } 70 | 71 | @Override 72 | public void setBounds(int x, int y, int width, int height) { 73 | super.setBounds(x, y, width, height); 74 | createImageShadow(); 75 | } 76 | 77 | private void createImageShadow() { 78 | int height = getHeight(); 79 | int width = getWidth(); 80 | if (width > 0 && height > 0) { 81 | imageShadow = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 82 | Graphics2D g2 = imageShadow.createGraphics(); 83 | BufferedImage img = createShadow(); 84 | if (img != null) { 85 | g2.drawImage(createShadow(), 0, 0, null); 86 | } 87 | g2.dispose(); 88 | } 89 | } 90 | 91 | private BufferedImage createShadow() { 92 | int width = getWidth() - (shadowSize.left + shadowSize.right); 93 | int height = getHeight() - (shadowSize.top + shadowSize.bottom); 94 | if (width > 0 && height > 0) { 95 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 96 | Graphics2D g2 = img.createGraphics(); 97 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 98 | g2.fill(new RoundRectangle2D.Double(0, 0, width, height, round, round)); 99 | g2.dispose(); 100 | return new ShadowRenderer(5, 0.3f, shadowColor).createShadow(img); 101 | } else { 102 | return null; 103 | } 104 | } 105 | 106 | private class TextUI extends BasicTextFieldUI { 107 | 108 | // Override this method to remove background or not paint background 109 | @Override 110 | protected void paintBackground(Graphics grphcs) { 111 | 112 | } 113 | } 114 | } 115 | --------------------------------------------------------------------------------