commit 81ed68172e1328d4459c2b63db4408cee87e6cb1 Author: Agnieszka Janicka Date: Thu Jun 2 22:32:46 2016 +0200 Dodanie projektu do repozytorium diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..2e3bdc5 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Library. + + + diff --git a/build/built-jar.properties b/build/built-jar.properties new file mode 100644 index 0000000..b8bf569 --- /dev/null +++ b/build/built-jar.properties @@ -0,0 +1,4 @@ +#Mon, 30 May 2016 12:41:20 +0200 + + +D\:\\PROJEKT\\Library= diff --git a/build/classes/.netbeans_automatic_build b/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/.netbeans_update_resources b/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/library/Album.class b/build/classes/library/Album.class new file mode 100644 index 0000000..52f4e5a Binary files /dev/null and b/build/classes/library/Album.class differ diff --git a/build/classes/library/AlbumFieldPattern$1.class b/build/classes/library/AlbumFieldPattern$1.class new file mode 100644 index 0000000..0d2a41c Binary files /dev/null and b/build/classes/library/AlbumFieldPattern$1.class differ diff --git a/build/classes/library/AlbumFieldPattern$2.class b/build/classes/library/AlbumFieldPattern$2.class new file mode 100644 index 0000000..7afb735 Binary files /dev/null and b/build/classes/library/AlbumFieldPattern$2.class differ diff --git a/build/classes/library/AlbumFieldPattern$3.class b/build/classes/library/AlbumFieldPattern$3.class new file mode 100644 index 0000000..aafb8b1 Binary files /dev/null and b/build/classes/library/AlbumFieldPattern$3.class differ diff --git a/build/classes/library/AlbumFieldPattern$4.class b/build/classes/library/AlbumFieldPattern$4.class new file mode 100644 index 0000000..29373a9 Binary files /dev/null and b/build/classes/library/AlbumFieldPattern$4.class differ diff --git a/build/classes/library/AlbumFieldPattern.class b/build/classes/library/AlbumFieldPattern.class new file mode 100644 index 0000000..dc0e9fd Binary files /dev/null and b/build/classes/library/AlbumFieldPattern.class differ diff --git a/build/classes/library/AlbumFieldPattern.form b/build/classes/library/AlbumFieldPattern.form new file mode 100644 index 0000000..042a88a --- /dev/null +++ b/build/classes/library/AlbumFieldPattern.form @@ -0,0 +1,190 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/library/Book.class b/build/classes/library/Book.class new file mode 100644 index 0000000..ff6c73d Binary files /dev/null and b/build/classes/library/Book.class differ diff --git a/build/classes/library/BookFieldPattern$1.class b/build/classes/library/BookFieldPattern$1.class new file mode 100644 index 0000000..4dc26be Binary files /dev/null and b/build/classes/library/BookFieldPattern$1.class differ diff --git a/build/classes/library/BookFieldPattern$2.class b/build/classes/library/BookFieldPattern$2.class new file mode 100644 index 0000000..3bb5e10 Binary files /dev/null and b/build/classes/library/BookFieldPattern$2.class differ diff --git a/build/classes/library/BookFieldPattern$3.class b/build/classes/library/BookFieldPattern$3.class new file mode 100644 index 0000000..c93ac8d Binary files /dev/null and b/build/classes/library/BookFieldPattern$3.class differ diff --git a/build/classes/library/BookFieldPattern$4.class b/build/classes/library/BookFieldPattern$4.class new file mode 100644 index 0000000..a5e643a Binary files /dev/null and b/build/classes/library/BookFieldPattern$4.class differ diff --git a/build/classes/library/BookFieldPattern$5.class b/build/classes/library/BookFieldPattern$5.class new file mode 100644 index 0000000..b2de6c9 Binary files /dev/null and b/build/classes/library/BookFieldPattern$5.class differ diff --git a/build/classes/library/BookFieldPattern.class b/build/classes/library/BookFieldPattern.class new file mode 100644 index 0000000..73c06b4 Binary files /dev/null and b/build/classes/library/BookFieldPattern.class differ diff --git a/build/classes/library/BookFieldPattern.form b/build/classes/library/BookFieldPattern.form new file mode 100644 index 0000000..3edb734 --- /dev/null +++ b/build/classes/library/BookFieldPattern.form @@ -0,0 +1,270 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/library/Item.class b/build/classes/library/Item.class new file mode 100644 index 0000000..2c10ea1 Binary files /dev/null and b/build/classes/library/Item.class differ diff --git a/build/classes/library/MainMenu$1.class b/build/classes/library/MainMenu$1.class new file mode 100644 index 0000000..9f7720e Binary files /dev/null and b/build/classes/library/MainMenu$1.class differ diff --git a/build/classes/library/MainMenu$2.class b/build/classes/library/MainMenu$2.class new file mode 100644 index 0000000..beb34c5 Binary files /dev/null and b/build/classes/library/MainMenu$2.class differ diff --git a/build/classes/library/MainMenu$3.class b/build/classes/library/MainMenu$3.class new file mode 100644 index 0000000..cf6de05 Binary files /dev/null and b/build/classes/library/MainMenu$3.class differ diff --git a/build/classes/library/MainMenu$4.class b/build/classes/library/MainMenu$4.class new file mode 100644 index 0000000..dceab63 Binary files /dev/null and b/build/classes/library/MainMenu$4.class differ diff --git a/build/classes/library/MainMenu$5.class b/build/classes/library/MainMenu$5.class new file mode 100644 index 0000000..124f851 Binary files /dev/null and b/build/classes/library/MainMenu$5.class differ diff --git a/build/classes/library/MainMenu$6.class b/build/classes/library/MainMenu$6.class new file mode 100644 index 0000000..bdaa70c Binary files /dev/null and b/build/classes/library/MainMenu$6.class differ diff --git a/build/classes/library/MainMenu$7.class b/build/classes/library/MainMenu$7.class new file mode 100644 index 0000000..b3ba5db Binary files /dev/null and b/build/classes/library/MainMenu$7.class differ diff --git a/build/classes/library/MainMenu$8.class b/build/classes/library/MainMenu$8.class new file mode 100644 index 0000000..d37db59 Binary files /dev/null and b/build/classes/library/MainMenu$8.class differ diff --git a/build/classes/library/MainMenu.class b/build/classes/library/MainMenu.class new file mode 100644 index 0000000..70e3da2 Binary files /dev/null and b/build/classes/library/MainMenu.class differ diff --git a/build/classes/library/MainMenu.form b/build/classes/library/MainMenu.form new file mode 100644 index 0000000..ac40e85 --- /dev/null +++ b/build/classes/library/MainMenu.form @@ -0,0 +1,218 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/library/Movie.class b/build/classes/library/Movie.class new file mode 100644 index 0000000..bec3e6d Binary files /dev/null and b/build/classes/library/Movie.class differ diff --git a/build/classes/library/MovieFieldPattern$1.class b/build/classes/library/MovieFieldPattern$1.class new file mode 100644 index 0000000..30c9031 Binary files /dev/null and b/build/classes/library/MovieFieldPattern$1.class differ diff --git a/build/classes/library/MovieFieldPattern$2.class b/build/classes/library/MovieFieldPattern$2.class new file mode 100644 index 0000000..6be2ba3 Binary files /dev/null and b/build/classes/library/MovieFieldPattern$2.class differ diff --git a/build/classes/library/MovieFieldPattern$3.class b/build/classes/library/MovieFieldPattern$3.class new file mode 100644 index 0000000..b992d78 Binary files /dev/null and b/build/classes/library/MovieFieldPattern$3.class differ diff --git a/build/classes/library/MovieFieldPattern$4.class b/build/classes/library/MovieFieldPattern$4.class new file mode 100644 index 0000000..c8d7e99 Binary files /dev/null and b/build/classes/library/MovieFieldPattern$4.class differ diff --git a/build/classes/library/MovieFieldPattern$5.class b/build/classes/library/MovieFieldPattern$5.class new file mode 100644 index 0000000..3eea9eb Binary files /dev/null and b/build/classes/library/MovieFieldPattern$5.class differ diff --git a/build/classes/library/MovieFieldPattern.class b/build/classes/library/MovieFieldPattern.class new file mode 100644 index 0000000..e0288fc Binary files /dev/null and b/build/classes/library/MovieFieldPattern.class differ diff --git a/build/classes/library/MovieFieldPattern.form b/build/classes/library/MovieFieldPattern.form new file mode 100644 index 0000000..837f72d --- /dev/null +++ b/build/classes/library/MovieFieldPattern.form @@ -0,0 +1,215 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/classes/library/Validation.class b/build/classes/library/Validation.class new file mode 100644 index 0000000..ae56ac3 Binary files /dev/null and b/build/classes/library/Validation.class differ diff --git a/dist/Library.jar b/dist/Library.jar new file mode 100644 index 0000000..78849cf Binary files /dev/null and b/dist/Library.jar differ diff --git a/dist/README.TXT b/dist/README.TXT new file mode 100644 index 0000000..96e2228 --- /dev/null +++ b/dist/README.TXT @@ -0,0 +1,32 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "Library.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, these files (folders) +are not copied. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..e93721a --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..89bd372 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0fe82c4e +build.xml.script.CRC32=6ee560e2 +build.xml.stylesheet.CRC32=8064a381@1.79.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=0fe82c4e +nbproject/build-impl.xml.script.CRC32=3785f28a +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..53fbddb --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\Agnieszka\\AppData\\Roaming\\NetBeans\\8.1\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..152c09b --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,12 @@ + + + + + + file:/D:/PROJEKT/Library/src/library/MovieFieldPattern.java + file:/D:/PROJEKT/Library/src/library/MainMenu.java + file:/D:/PROJEKT/Library/src/library/BookFieldPattern.java + file:/D:/PROJEKT/Library/src/library/WelcomeLogon.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..3d5ff59 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,96 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Library +application.vendor=Agnieszka +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Library.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +main.class=library.MainMenu +# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. +manifest.custom.application.library.allowable.codebase= +# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. +manifest.custom.caller.allowable.codebase= +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..09271a9 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Library + + + + + + + + + diff --git a/src/library/Album.java b/src/library/Album.java new file mode 100644 index 0000000..e914a90 --- /dev/null +++ b/src/library/Album.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +/** + * + * @author Agnieszka + */ +public class Album extends Item { + Album(){ + this.setName("NULL"); + this.setYear(0); + this.setCategory("NULL"); + this.musican= "NULL"; + } + @Override + public void insertToDB(){ + String query = "INSERT INTO albums VALUES(NULL, '" +this.getName() + "', '" + this.getMusican() + "', '" + this.getYear() + "', '"+ this.getCategory() + "');"; +}; +@Override +public void delFromDB(){ + String query = "DELETE FROM albums WHERE id=" + this.getId() + ";"; +}; +@Override +public void editInDB(){ + +}; + @Override +public void setIdFromDB(){ + //String query = "SELECT id FROM albums WHERE musican LIKE " + this.getISBN() +";"; + } + +public void setMusican(String s){ + this.musican = s; +} +public String getMusican(){ + return this.musican; +} + private String musican; + +} diff --git a/src/library/AlbumFieldPattern.form b/src/library/AlbumFieldPattern.form new file mode 100644 index 0000000..042a88a --- /dev/null +++ b/src/library/AlbumFieldPattern.form @@ -0,0 +1,190 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/library/AlbumFieldPattern.java b/src/library/AlbumFieldPattern.java new file mode 100644 index 0000000..f22a28e --- /dev/null +++ b/src/library/AlbumFieldPattern.java @@ -0,0 +1,235 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/** + * + * @author Agnieszka + */ +public class AlbumFieldPattern extends javax.swing.JFrame { + + /** + * Creates new form bookFieldPattern + */ + public AlbumFieldPattern() { + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + initComponents(); + } + public AlbumFieldPattern(boolean required) { + initComponents(); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + albumTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); + } + public boolean ifreturn= false, ifborrow= false, add= false, delete = false, edit = false; + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + Title = new javax.swing.JLabel(); + albumTitle = new javax.swing.JTextField(); + lmusican = new javax.swing.JLabel(); + musican = new javax.swing.JTextField(); + lyear = new javax.swing.JLabel(); + year = new javax.swing.JTextField(); + lcategory = new javax.swing.JLabel(); + Category = new javax.swing.JComboBox<>(); + mainlabel = new javax.swing.JLabel(); + SaveChanges = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + Title.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + Title.setText("Tytuł:"); + + albumTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + lmusican.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lmusican.setText("Twórca:"); + + musican.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + lyear.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lyear.setText("Rok:"); + + year.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + year.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + yearActionPerformed(evt); + } + }); + + lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lcategory.setText("Gatunek:"); + + Category.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Jazz", "Rap", "Rock", "Muzyka Klasyczna", "Reggae", "Pop", "Elektroniczna" })); + Category.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CategoryActionPerformed(evt); + } + }); + + mainlabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + mainlabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + mainlabel.setText("Wypełnij formualrz:"); + + SaveChanges.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + SaveChanges.setText("OK"); + SaveChanges.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + SaveChangesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(Title) + .addComponent(lmusican)) + .addGap(56, 56, 56) + .addComponent(mainlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(lyear, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(musican, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(albumTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(lcategory, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(26, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(mainlabel) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(Title) + .addComponent(albumTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lmusican) + .addComponent(musican, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lyear) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lcategory) + .addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(SaveChanges) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + public void ChangeOkButtonText(String s) { + this.SaveChanges.setText(s); + } + + private void CategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CategoryActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_CategoryActionPerformed + + private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed + if(this.ifborrow){ + JOptionPane.showMessageDialog(null, "tryb wypożycz"); + } + else if(this.ifreturn){ + JOptionPane.showMessageDialog(null, "tryb zwróć"); + } + else if(this.add){ + JOptionPane.showMessageDialog(null, "DODAJ"); + } + else if(this.edit){ + JOptionPane.showMessageDialog(null, "EDYTUJ"); + } + else if(this.delete){ + JOptionPane.showMessageDialog(null, "USUŃ"); + } + dispose(); + }//GEN-LAST:event_SaveChangesActionPerformed + + private void yearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_yearActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(AlbumFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(AlbumFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(AlbumFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(AlbumFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new AlbumFieldPattern().setVisible(false); + } + }); + + + + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox Category; + private javax.swing.JButton SaveChanges; + private javax.swing.JLabel Title; + private javax.swing.JTextField albumTitle; + private javax.swing.JLabel lcategory; + private javax.swing.JLabel lmusican; + private javax.swing.JLabel lyear; + private javax.swing.JLabel mainlabel; + private javax.swing.JTextField musican; + private javax.swing.JTextField year; + // End of variables declaration//GEN-END:variables +} diff --git a/src/library/Book.java b/src/library/Book.java new file mode 100644 index 0000000..4267391 --- /dev/null +++ b/src/library/Book.java @@ -0,0 +1,66 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +/** + * + * @author Agnieszka + */ +public class Book extends Item{ + Book(){ + this.setName("NULL"); + this.setYear(0); + this.setCategory("NULL"); + this.authorName = "NULL"; + this.authorSurname = "NULL"; + this.ISBN = "NULL"; + this.publishing = "NULL"; + } +@Override +public void insertToDB(){ + String query = "INSERT INTO books VALUES(NULL, '" +this.getName() + "', '" + this.getAuthorName() + "', '" + this.getAuthorSurname() + "', '"+ this.getPublishing() + "', '"+ this.getYear() + "', '"+ this.getISBN() + "', '"+ this.getCategory() + "');"; +}; +@Override +public void delFromDB(){ + String query = "DELETE FROM books WHERE id=" + this.getId() + ";"; +}; +@Override +public void editInDB(){ + +}; + /*public void insertQuery(){ + System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');"); + }*/ + @Override +public void setIdFromDB(){ + String query = "SELECT id FROM books WHERE isbn LIKE " + this.getISBN() +";"; + } +public void setPublishing(String s){ + this.publishing = s; + } +public void setAuthorName(String s){ + this.authorName = s; + } +public void setAuthorSurname(String s){ + this.authorSurname = s; + } +public void setISBN(String s){ + this.ISBN = s; + } +public String getAuthorName(){ + return this.authorName; + } +public String getAuthorSurname(){ + return this.authorSurname; + } +public String getPublishing(){ + return this.publishing; + } +public String getISBN(){ + return this.publishing; + } +private String authorName, authorSurname, publishing, ISBN; +} diff --git a/src/library/BookFieldPattern.form b/src/library/BookFieldPattern.form new file mode 100644 index 0000000..3edb734 --- /dev/null +++ b/src/library/BookFieldPattern.form @@ -0,0 +1,270 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/library/BookFieldPattern.java b/src/library/BookFieldPattern.java new file mode 100644 index 0000000..e24f948 --- /dev/null +++ b/src/library/BookFieldPattern.java @@ -0,0 +1,305 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +import java.util.Arrays; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/** + * + * @author Agnieszka + */ +public class BookFieldPattern extends javax.swing.JFrame { + + /** + * Creates new form bookFieldPattern + */ + public BookFieldPattern() { + initComponents(); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + public BookFieldPattern(boolean required) { + initComponents(); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); + } + + + public boolean ifreturn= false, ifborrow= false, add= false, delete = false, edit = false; + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + Title = new javax.swing.JLabel(); + bookTitle = new javax.swing.JTextField(); + authorname = new javax.swing.JLabel(); + authorName = new javax.swing.JTextField(); + authorSurname = new javax.swing.JTextField(); + authorsurname = new javax.swing.JLabel(); + lpublishing = new javax.swing.JLabel(); + publishing = new javax.swing.JTextField(); + lyear = new javax.swing.JLabel(); + year = new javax.swing.JTextField(); + lISBN = new javax.swing.JLabel(); + ISBN = new javax.swing.JTextField(); + lcategory = new javax.swing.JLabel(); + Category = new javax.swing.JComboBox<>(); + mainlabel = new javax.swing.JLabel(); + SaveChanges = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + Title.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + Title.setText("Tytuł:"); + + bookTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", this.add)); + bookTitle.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bookTitleActionPerformed(evt); + } + }); + + authorname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + authorname.setText("Imię autora:"); + + authorName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + authorSurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + authorSurname.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + authorSurnameActionPerformed(evt); + } + }); + + authorsurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + authorsurname.setText("Nazwisko autora:"); + + lpublishing.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lpublishing.setText("Wydawnictwo:"); + + publishing.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + lyear.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lyear.setText("Rok wydania:"); + + year.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + lISBN.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lISBN.setText("ISBN:"); + + ISBN.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lcategory.setText("Kategoria:"); + + Category.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Przygodowe", "Naukowe", "Powieść", "Poezja", "Kryminał", "Dla dzieci", "Psychologiczne", "Podręczniki" })); + Category.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CategoryActionPerformed(evt); + } + }); + + mainlabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + mainlabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + mainlabel.setText("Wypełnij formualrz:"); + + SaveChanges.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + SaveChanges.setText("OK"); + SaveChanges.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + SaveChangesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(Title) + .addComponent(authorname)) + .addGap(35, 35, 35) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(authorName, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(bookTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 20, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(lcategory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lISBN, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lyear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(authorsurname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lpublishing, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(authorSurname) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(publishing) + .addComponent(ISBN) + .addComponent(Category, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(mainlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(71, 71, 71)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(mainlabel) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(Title) + .addComponent(bookTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(authorname) + .addComponent(authorName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(authorsurname) + .addComponent(authorSurname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lpublishing) + .addComponent(publishing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lyear) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lISBN) + .addComponent(ISBN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lcategory) + .addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(SaveChanges) + .addContainerGap(33, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void CategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CategoryActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_CategoryActionPerformed + + public void ChangeOkButtonText(String s) { + this.SaveChanges.setText(s); + } + + + private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed + if(this.ifborrow){ + JOptionPane.showMessageDialog(null, "tryb wypożycz"); + } + else if(this.ifreturn){ + JOptionPane.showMessageDialog(null, "tryb zwróć"); + } + else if(this.add){ + Book b = new Book(); + /* + b.name = bookTitle.getText(); + b.authorName = authorName.getText(); + b.authorSurname = authorSurname.getText(); + b.publishing = publishing.getText(); + b.year = Integer.parseInt(year.getText()); + b.ISBN = ISBN.getText(); + b.category = Category.getSelectedItem().toString(); + b.insertQuery(); + */ + } + else if(this.edit){ + JOptionPane.showMessageDialog(null, "EDYTUJ"); + } + else if(this.delete){ + JOptionPane.showMessageDialog(null, "USUŃ"); + } + dispose(); + }//GEN-LAST:event_SaveChangesActionPerformed + + private void authorSurnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authorSurnameActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_authorSurnameActionPerformed + + private void bookTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bookTitleActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_bookTitleActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(BookFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(BookFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(BookFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(BookFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new BookFieldPattern().setVisible(false); + } + }); + + + + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox Category; + private javax.swing.JTextField ISBN; + private javax.swing.JButton SaveChanges; + private javax.swing.JLabel Title; + private javax.swing.JTextField authorName; + private javax.swing.JTextField authorSurname; + private javax.swing.JLabel authorname; + private javax.swing.JLabel authorsurname; + private javax.swing.JTextField bookTitle; + private javax.swing.JLabel lISBN; + private javax.swing.JLabel lcategory; + private javax.swing.JLabel lpublishing; + private javax.swing.JLabel lyear; + private javax.swing.JLabel mainlabel; + private javax.swing.JTextField publishing; + private javax.swing.JTextField year; + // End of variables declaration//GEN-END:variables +} diff --git a/src/library/Item.java b/src/library/Item.java new file mode 100644 index 0000000..0dc8940 --- /dev/null +++ b/src/library/Item.java @@ -0,0 +1,49 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +/** + * + * @author Agnieszka + + */ +public abstract class Item { + +public abstract void insertToDB(); +public abstract void delFromDB(); +public abstract void editInDB(); +public abstract void setIdFromDB(); + + public void setName(String s){ + this.name = s; + } + public void setCategory(String s){ + this.category = s; + } + public void setYear(int i){ + this.year = i; + } + public void setId(int i){ + this.id = i; + } + + + public String getName(){ + return this.name; + } + public String getCategory(){ + return this.category; + } + public int getYear(){ + return this.year; + } + public int getId(){ + return this.id; + } + + private String name, category; + private int year, id; +} diff --git a/src/library/MainMenu.form b/src/library/MainMenu.form new file mode 100644 index 0000000..ac40e85 --- /dev/null +++ b/src/library/MainMenu.form @@ -0,0 +1,218 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/library/MainMenu.java b/src/library/MainMenu.java new file mode 100644 index 0000000..7f7bbfb --- /dev/null +++ b/src/library/MainMenu.java @@ -0,0 +1,315 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +import javax.swing.JOptionPane; + +/** + * + * @author Agnieszka + */ +public class MainMenu extends javax.swing.JFrame { + + /** + * Creates new form mainMenu + */ + public MainMenu() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + mode = new javax.swing.ButtonGroup(); + programTitle = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + searchButtonsPanel = new javax.swing.JPanel(); + bAlbum = new javax.swing.JButton(); + bMovie = new javax.swing.JButton(); + bBook = new javax.swing.JButton(); + radioBAdd = new javax.swing.JRadioButton(); + radioBEdit = new javax.swing.JRadioButton(); + radioBSearch = new javax.swing.JRadioButton(); + bUser = new javax.swing.JButton(); + radioBDelete1 = new javax.swing.JRadioButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + programTitle.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N + programTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + programTitle.setText("Library Manager 2016"); + + searchButtonsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + bAlbum.setText("Albumu..."); + bAlbum.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bAlbumActionPerformed(evt); + } + }); + + bMovie.setText("Filmu.."); + bMovie.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bMovieActionPerformed(evt); + } + }); + + bBook.setText("Książki..."); + bBook.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bBookActionPerformed(evt); + } + }); + + mode.add(radioBAdd); + radioBAdd.setText("Dodawanie"); + radioBAdd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioBAddActionPerformed(evt); + } + }); + + mode.add(radioBEdit); + radioBEdit.setText("Modyfikacja"); + radioBEdit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioBEditActionPerformed(evt); + } + }); + + mode.add(radioBSearch); + radioBSearch.setSelected(true); + radioBSearch.setText("Wyszukiwarka"); + radioBSearch.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioBSearchActionPerformed(evt); + } + }); + + bUser.setText("Czytelnika..."); + bUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bUserActionPerformed(evt); + } + }); + + mode.add(radioBDelete1); + radioBDelete1.setText("Usuwanie"); + radioBDelete1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioBDelete1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout searchButtonsPanelLayout = new javax.swing.GroupLayout(searchButtonsPanel); + searchButtonsPanel.setLayout(searchButtonsPanelLayout); + searchButtonsPanelLayout.setHorizontalGroup( + searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(searchButtonsPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(searchButtonsPanelLayout.createSequentialGroup() + .addComponent(radioBAdd) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(radioBEdit) + .addGap(7, 7, 7) + .addComponent(radioBDelete1) + .addGap(39, 39, 39) + .addComponent(radioBSearch)) + .addGroup(searchButtonsPanelLayout.createSequentialGroup() + .addComponent(bBook) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bMovie) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bAlbum) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(bUser))) + .addContainerGap(111, Short.MAX_VALUE)) + ); + searchButtonsPanelLayout.setVerticalGroup( + searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(searchButtonsPanelLayout.createSequentialGroup() + .addGap(17, 17, 17) + .addGroup(searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(radioBAdd) + .addComponent(radioBEdit) + .addComponent(radioBSearch) + .addComponent(radioBDelete1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(bBook) + .addComponent(bMovie) + .addComponent(bAlbum) + .addComponent(bUser)) + .addGap(83, 83, 83)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(programTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(359, 359, 359) + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGap(26, 26, 26) + .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(21, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(programTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 282, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void bMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bMovieActionPerformed + if(radioBAdd.getModel().isSelected()){ + MovieFieldPattern b = new MovieFieldPattern(true); + b.setVisible(true); + b.add=true; + } + if(radioBEdit.getModel().isSelected()){ + MovieFieldPattern b = new MovieFieldPattern(); + b.setVisible(true); + b.edit=true; + } + if(radioBSearch.getModel().isSelected()){ + MovieFieldPattern b = new MovieFieldPattern(); + b.setVisible(true); + b.delete=true; + } + }//GEN-LAST:event_bMovieActionPerformed + + private void bAlbumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAlbumActionPerformed + + if(radioBAdd.getModel().isSelected()){ + AlbumFieldPattern b = new AlbumFieldPattern(true); + b.setVisible(true); + b.add=true; + } + if(radioBEdit.getModel().isSelected()){ + AlbumFieldPattern b = new AlbumFieldPattern(); + b.setVisible(true); + b.edit=true; + } + if(radioBSearch.getModel().isSelected()){ + MovieFieldPattern b = new MovieFieldPattern(); + b.setVisible(true); + b.delete=true; + } + }//GEN-LAST:event_bAlbumActionPerformed + + private void bUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bUserActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_bUserActionPerformed + + private void radioBEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBEditActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_radioBEditActionPerformed + + private void radioBSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBSearchActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_radioBSearchActionPerformed + + private void radioBAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBAddActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_radioBAddActionPerformed + + private void bBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBookActionPerformed + if(radioBAdd.getModel().isSelected()){ + BookFieldPattern b = new BookFieldPattern(true); + b.setVisible(true); + b.add=true; + } + if(radioBEdit.getModel().isSelected()){ + BookFieldPattern b = new BookFieldPattern(); + b.setVisible(true); + b.edit=true; + } + if(radioBSearch.getModel().isSelected()){ + BookFieldPattern b = new BookFieldPattern(); + b.setVisible(true); + b.delete=true; + } + + }//GEN-LAST:event_bBookActionPerformed + + private void radioBDelete1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBDelete1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_radioBDelete1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(MainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(MainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(MainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(MainMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(() -> { + new MainMenu().setVisible(true); + /* java.awt.EventQueue.invokeLater(() ->*/ }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton bAlbum; + private javax.swing.JButton bBook; + private javax.swing.JButton bMovie; + private javax.swing.JButton bUser; + private javax.swing.JLabel jLabel1; + private javax.swing.ButtonGroup mode; + private javax.swing.JLabel programTitle; + private javax.swing.JRadioButton radioBAdd; + private javax.swing.JRadioButton radioBDelete1; + private javax.swing.JRadioButton radioBEdit; + private javax.swing.JRadioButton radioBSearch; + private javax.swing.JPanel searchButtonsPanel; + // End of variables declaration//GEN-END:variables +} diff --git a/src/library/Movie.java b/src/library/Movie.java new file mode 100644 index 0000000..7497d66 --- /dev/null +++ b/src/library/Movie.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +/** + * + * @author Agnieszka + */ +public class Movie extends Item{ + + private String director; + +@Override +public void insertToDB(){ + //String query = "INSERT INTO books VALUES(NULL, '" +this.getName() + "', '" + this.getAuthorName() + "', '" + this.getAuthorSurname() + "', '"+ this.getPublishing() + "', '"+ this.getYear() + "', '"+ this.getISBN() + "', '"+ this.getCategory() + "');"; +}; +@Override +public void delFromDB(){ + String query = "DELETE FROM books WHERE id=" + this.getId() + ";"; +}; +@Override +public void editInDB(){ + +}; + /*public void insertQuery(){ + System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');"); + }*/ + @Override +public void setIdFromDB(){ + // String query = "SELECT id FROM books WHERE isbn LIKE " + this.getISBN() +";"; + } +} diff --git a/src/library/MovieFieldPattern.form b/src/library/MovieFieldPattern.form new file mode 100644 index 0000000..837f72d --- /dev/null +++ b/src/library/MovieFieldPattern.form @@ -0,0 +1,215 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/library/MovieFieldPattern.java b/src/library/MovieFieldPattern.java new file mode 100644 index 0000000..4e0b90f --- /dev/null +++ b/src/library/MovieFieldPattern.java @@ -0,0 +1,256 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/** + * + * @author Agnieszka + */ +public class MovieFieldPattern extends javax.swing.JFrame { + + /** + * Creates new form bookFieldPattern + */ + public MovieFieldPattern() { + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + initComponents(); + } + public MovieFieldPattern(boolean required) { + initComponents(); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + movieTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); + } + public boolean ifreturn= false, ifborrow= false, add= false, delete = false, edit = false; + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + Title = new javax.swing.JLabel(); + movieTitle = new javax.swing.JTextField(); + directorrname = new javax.swing.JLabel(); + director = new javax.swing.JTextField(); + script = new javax.swing.JTextField(); + authorsurname = new javax.swing.JLabel(); + lyear = new javax.swing.JLabel(); + year = new javax.swing.JTextField(); + lcategory = new javax.swing.JLabel(); + Category = new javax.swing.JComboBox<>(); + mainlabel = new javax.swing.JLabel(); + SaveChanges = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + Title.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + Title.setText("Tytuł:"); + + movieTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + directorrname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + directorrname.setText("Reżyser:"); + + director.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + + script.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + script.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + scriptActionPerformed(evt); + } + }); + + authorsurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + authorsurname.setText("Scenariusz:"); + + lyear.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lyear.setText("Rok:"); + + year.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + year.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + yearActionPerformed(evt); + } + }); + + lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + lcategory.setText("Kategoria:"); + + Category.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Kryminał", "Thriller", "Przygodowy", "Animowany", "Akcji", "Dla dzieci", "Komedia", "Horror" })); + Category.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CategoryActionPerformed(evt); + } + }); + + mainlabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + mainlabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + mainlabel.setText("Wypełnij formualrz:"); + + SaveChanges.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + SaveChanges.setText("OK"); + SaveChanges.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + SaveChangesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(Title) + .addComponent(directorrname)) + .addGap(56, 56, 56) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(director, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(movieTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(mainlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(lcategory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lyear, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) + .addComponent(authorsurname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(17, 17, 17) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(script, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(21, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(mainlabel) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(Title) + .addComponent(movieTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(directorrname) + .addComponent(director, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(authorsurname) + .addComponent(script, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lyear) + .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lcategory) + .addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(33, 33, 33) + .addComponent(SaveChanges) + .addContainerGap(26, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + public void ChangeOkButtonText(String s) { + this.SaveChanges.setText(s); + } + + private void CategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CategoryActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_CategoryActionPerformed + + private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed + if(this.ifborrow){ + JOptionPane.showMessageDialog(null, "tryb wypożycz"); + } + else if(this.ifreturn){ + JOptionPane.showMessageDialog(null, "tryb zwróć"); + } + else if(this.add){ + JOptionPane.showMessageDialog(null, "DODAJ"); + } + else if(this.edit){ + JOptionPane.showMessageDialog(null, "EDYTUJ"); + } + else if(this.delete){ + JOptionPane.showMessageDialog(null, "USUŃ"); + } + dispose(); + }//GEN-LAST:event_SaveChangesActionPerformed + + private void scriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scriptActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_scriptActionPerformed + + private void yearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_yearActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(MovieFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(MovieFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(MovieFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(MovieFieldPattern.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new MovieFieldPattern().setVisible(false); + } + }); + + + + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox Category; + private javax.swing.JButton SaveChanges; + private javax.swing.JLabel Title; + private javax.swing.JLabel authorsurname; + private javax.swing.JTextField director; + private javax.swing.JLabel directorrname; + private javax.swing.JLabel lcategory; + private javax.swing.JLabel lyear; + private javax.swing.JLabel mainlabel; + private javax.swing.JTextField movieTitle; + private javax.swing.JTextField script; + private javax.swing.JTextField year; + // End of variables declaration//GEN-END:variables +} diff --git a/src/library/Validation.java b/src/library/Validation.java new file mode 100644 index 0000000..4e01177 --- /dev/null +++ b/src/library/Validation.java @@ -0,0 +1,57 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package library; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.InputVerifier; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTextField; + +/** + * + * @author Agnieszka + * walitator używający wyrażeń regularnych do sprawdzania pól formularzy + * wyrażenia regularne jako parametr konstuktora + */ +public class Validation extends InputVerifier { + public Validation(String ex, boolean rq){ + expression=ex; + required = rq; + } + @Override + public boolean verify(JComponent input) { + JTextField tf = (JTextField) input; + Pattern p = Pattern.compile(expression); + Matcher m = p.matcher(tf.getText()); + if(required) { + if (m.matches()){ + return true; + } + else{ + if("".equals(tf.getText())){ + JOptionPane.showMessageDialog(null, "Pole wymagane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); + } + else{ + JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); + } + return false; + } + } + else{ + if (m.matches() || "".equals(tf.getText())){ + return true; + } + else{ + JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); + return false; + } + } + } + String expression; + boolean required = false; +} \ No newline at end of file