initiated
This commit is contained in:
parent
d55bd88ec7
commit
47f0d2b589
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="Paint" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project Paint.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="Paint-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,8 @@
|
||||||
|
build.xml.data.CRC32=212a4d8f
|
||||||
|
build.xml.script.CRC32=6f3bd992
|
||||||
|
build.xml.stylesheet.CRC32=8064a381@1.80.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=212a4d8f
|
||||||
|
nbproject/build-impl.xml.script.CRC32=022c0254
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
compile.on.save=true
|
||||||
|
do.depend=false
|
||||||
|
do.jar=true
|
||||||
|
javac.debug=true
|
||||||
|
javadoc.preview=true
|
||||||
|
user.properties.file=/home/piyush/.netbeans/8.2/build.properties
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
|
<group>
|
||||||
|
<file>file:/home/piyush/NetBeansProjects/Paint/src/paint/Paint.java</file>
|
||||||
|
<file>file:/home/piyush/NetBeansProjects/Paint/src/paint/PaintPanel.java</file>
|
||||||
|
<file>file:/home/piyush/NetBeansProjects/Paint/src/paint/ColorChoose.java</file>
|
||||||
|
</group>
|
||||||
|
</open-files>
|
||||||
|
</project-private>
|
||||||
|
|
@ -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=Paint
|
||||||
|
application.vendor=piyush
|
||||||
|
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}/Paint.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=paint.Paint
|
||||||
|
# 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
|
||||||
|
project.license=mit
|
||||||
|
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
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>Paint</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="col" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
<Component id="jButton1" min="-2" pref="85" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="col" min="-2" pref="284" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="0" pref="9" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JColorChooser" name="col">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||||
|
</AuxValues>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="close"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
||||||
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright 2019 piyush.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package paint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author piyush
|
||||||
|
*/
|
||||||
|
public class ColorChoose extends javax.swing.JDialog {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form ColorChoos
|
||||||
|
*/
|
||||||
|
public ColorChoose(java.awt.Frame parent, boolean modal) {
|
||||||
|
super(parent, modal);
|
||||||
|
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")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
col = new javax.swing.JColorChooser();
|
||||||
|
jButton1 = new javax.swing.JButton();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
jButton1.setText("close");
|
||||||
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(col, javax.swing.GroupLayout.DEFAULT_SIZE, 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(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(col, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton1)
|
||||||
|
.addGap(0, 9, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||||
|
this.setVisible(false);
|
||||||
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String args[]) {
|
||||||
|
/* Set the Nimbus look and feel */
|
||||||
|
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||||
|
/* 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(ColorChoose.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (InstantiationException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(ColorChoose.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(ColorChoose.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(ColorChoose.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
/* Create and display the dialog */
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
ColorChoose dialog = new ColorChoose(new javax.swing.JFrame(), true);
|
||||||
|
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
public javax.swing.JColorChooser col;
|
||||||
|
private javax.swing.JButton jButton1;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,168 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Component id="paint" alignment="1" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||||
|
<Component id="paint" pref="335" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="paint.PaintPanel" name="paint">
|
||||||
|
<Properties>
|
||||||
|
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||||
|
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||||
|
<Color blue="fe" green="bd" red="7b" type="rgb"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton5" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton6" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton7" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton8" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton9" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="181" max="32767" attributes="0"/>
|
||||||
|
<Component id="jToggleButton1" min="-2" pref="89" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton10" min="-2" pref="33" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton7" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton8" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton9" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton10" alignment="3" min="-2" pref="33" max="-2" attributes="0"/>
|
||||||
|
<Component id="jToggleButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
|
<Font name="Noto Sans" size="18" style="0"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="text" type="java.lang.String" value="Paint"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton5">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="pencil"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton6">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="line"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton6ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton7">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="rectangle"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton7ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton8">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="oval"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton8ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton9">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="circle"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton9ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton10">
|
||||||
|
<Properties>
|
||||||
|
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||||
|
<Color blue="0" green="0" red="0" type="rgb"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton10ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="filled"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleButton1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
||||||
|
|
@ -0,0 +1,236 @@
|
||||||
|
/*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright 2019 piyush.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package paint;
|
||||||
|
|
||||||
|
import javax.swing.JColorChooser;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.colorchooser.DefaultColorSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author piyush
|
||||||
|
*/
|
||||||
|
public class Paint extends javax.swing.JFrame {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form JFrame
|
||||||
|
*/
|
||||||
|
public Paint() {
|
||||||
|
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")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
paint = new paint.PaintPanel();
|
||||||
|
jPanel1 = new javax.swing.JPanel();
|
||||||
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
jButton5 = new javax.swing.JButton();
|
||||||
|
jButton6 = new javax.swing.JButton();
|
||||||
|
jButton7 = new javax.swing.JButton();
|
||||||
|
jButton8 = new javax.swing.JButton();
|
||||||
|
jButton9 = new javax.swing.JButton();
|
||||||
|
jButton10 = new javax.swing.JButton();
|
||||||
|
jToggleButton1 = new javax.swing.JToggleButton();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
paint.setBackground(new java.awt.Color(255, 255, 255));
|
||||||
|
|
||||||
|
jPanel1.setBackground(new java.awt.Color(123, 189, 254));
|
||||||
|
|
||||||
|
jLabel1.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N
|
||||||
|
jLabel1.setText("Paint");
|
||||||
|
|
||||||
|
jButton5.setText("pencil");
|
||||||
|
jButton5.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton5ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton6.setText("line");
|
||||||
|
jButton6.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton6ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton7.setText("rectangle");
|
||||||
|
jButton7.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton7ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton8.setText("oval");
|
||||||
|
jButton8.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton8ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton9.setText("circle");
|
||||||
|
jButton9.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton9ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton10.setBackground(new java.awt.Color(0, 0, 0));
|
||||||
|
jButton10.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton10ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jToggleButton1.setText("filled");
|
||||||
|
jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jToggleButton1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
|
jPanel1Layout.setHorizontalGroup(
|
||||||
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton5)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton6)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton7)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton8)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton9)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 181, Short.MAX_VALUE)
|
||||||
|
.addComponent(jToggleButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
jPanel1Layout.setVerticalGroup(
|
||||||
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addComponent(jButton5)
|
||||||
|
.addComponent(jButton6)
|
||||||
|
.addComponent(jButton7)
|
||||||
|
.addComponent(jButton8)
|
||||||
|
.addComponent(jButton9)
|
||||||
|
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(jToggleButton1))
|
||||||
|
.addGap(0, 0, 0))
|
||||||
|
);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(paint, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, 0)
|
||||||
|
.addComponent(paint, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
|
||||||
|
.addGap(0, 0, 0))
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
|
||||||
|
paint.shape = "pencil";
|
||||||
|
}//GEN-LAST:event_jButton5ActionPerformed
|
||||||
|
|
||||||
|
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
|
||||||
|
paint.shape = "line";
|
||||||
|
}//GEN-LAST:event_jButton6ActionPerformed
|
||||||
|
|
||||||
|
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
|
||||||
|
paint.shape = "rect";
|
||||||
|
}//GEN-LAST:event_jButton7ActionPerformed
|
||||||
|
|
||||||
|
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
|
||||||
|
paint.shape = "oval";
|
||||||
|
}//GEN-LAST:event_jButton8ActionPerformed
|
||||||
|
|
||||||
|
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
|
||||||
|
paint.shape = "circle";
|
||||||
|
}//GEN-LAST:event_jButton9ActionPerformed
|
||||||
|
|
||||||
|
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
|
||||||
|
ColorChoose ch = new ColorChoose(this, true);
|
||||||
|
ch.col.setColor(paint.color);
|
||||||
|
ch.setVisible(true);
|
||||||
|
paint.color = ch.col.getColor();
|
||||||
|
jButton10.setBackground(paint.color);
|
||||||
|
ch.dispose();
|
||||||
|
}//GEN-LAST:event_jButton10ActionPerformed
|
||||||
|
|
||||||
|
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
|
||||||
|
paint.isfilled = jToggleButton1.isSelected();
|
||||||
|
}//GEN-LAST:event_jToggleButton1ActionPerformed
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String args[]) {
|
||||||
|
|
||||||
|
/* Create and display the form */
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
new Paint().setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton jButton10;
|
||||||
|
private javax.swing.JButton jButton5;
|
||||||
|
private javax.swing.JButton jButton6;
|
||||||
|
private javax.swing.JButton jButton7;
|
||||||
|
private javax.swing.JButton jButton8;
|
||||||
|
private javax.swing.JButton jButton9;
|
||||||
|
private javax.swing.JLabel jLabel1;
|
||||||
|
private javax.swing.JPanel jPanel1;
|
||||||
|
private javax.swing.JToggleButton jToggleButton1;
|
||||||
|
private paint.PaintPanel paint;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,208 @@
|
||||||
|
/*
|
||||||
|
* The MIT License
|
||||||
|
*
|
||||||
|
* Copyright 2019 piyush.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package paint;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author piyush
|
||||||
|
*/
|
||||||
|
public class PaintPanel extends Component implements MouseMotionListener, MouseListener
|
||||||
|
{
|
||||||
|
public ArrayList<Part> parts = new ArrayList<>();
|
||||||
|
public Color color = Color.BLACK;
|
||||||
|
public String shape = "pencil";
|
||||||
|
public Boolean isfilled = false;
|
||||||
|
|
||||||
|
public PaintPanel()
|
||||||
|
{
|
||||||
|
this.addMouseListener(this);
|
||||||
|
this.addMouseMotionListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g)
|
||||||
|
{
|
||||||
|
for(Part part : parts)
|
||||||
|
{
|
||||||
|
g.setColor(part.color);
|
||||||
|
if(part.shape.equals("pencil"))
|
||||||
|
{
|
||||||
|
int x = part.cords.get(0).x;
|
||||||
|
int y = part.cords.get(0).y;
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = 1; i < part.cords.size(); i++)
|
||||||
|
{
|
||||||
|
g.drawLine(x, y, part.cords.get(i).x, part.cords.get(i).y);
|
||||||
|
x = part.cords.get(i).x;
|
||||||
|
y = part.cords.get(i).y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(part.shape.equals("line"))
|
||||||
|
{
|
||||||
|
if(part.cords.size() > 1) g.drawLine(part.cords.get(0).x, part.cords.get(0).y, part.cords.get(1).x, part.cords.get(1).y);
|
||||||
|
}
|
||||||
|
else if(part.shape.equals("rect"))
|
||||||
|
{
|
||||||
|
if(part.cords.size() > 1)
|
||||||
|
{
|
||||||
|
int x1,y1,x2,y2;
|
||||||
|
x1 = Math.min(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y1 = Math.min(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
x2 = Math.max(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y2 = Math.max(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
if(part.isfilled) g.fillRect(x1,y1,x2 - x1,y2 - y1);
|
||||||
|
else g.drawRect(x1,y1,x2 - x1,y2 - y1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(part.shape.equals("oval"))
|
||||||
|
{
|
||||||
|
if(part.cords.size() > 1)
|
||||||
|
{
|
||||||
|
int x1,y1,x2,y2;
|
||||||
|
x1 = Math.min(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y1 = Math.min(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
x2 = Math.max(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y2 = Math.max(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
if(part.isfilled) g.fillOval(x1,y1,x2 - x1,y2 - y1);
|
||||||
|
else g.drawOval(x1,y1,x2 - x1,y2 - y1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(part.shape.equals("circle"))
|
||||||
|
{
|
||||||
|
if(part.cords.size() > 1)
|
||||||
|
{
|
||||||
|
int x1,y1,x2,y2,r;
|
||||||
|
x1 = Math.min(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y1 = Math.min(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
x2 = Math.max(part.cords.get(0).x, part.cords.get(1).x);
|
||||||
|
y2 = Math.max(part.cords.get(0).y, part.cords.get(1).y);
|
||||||
|
r = (int)Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
|
||||||
|
if(part.isfilled) g.fillOval(part.cords.get(0).x - r,part.cords.get(0).y - r,2 * r,2 * r);
|
||||||
|
else g.drawOval(part.cords.get(0).x - r,part.cords.get(0).y - r,2 * r,2 * r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
if(shape.equals("pencil")) parts.get(parts.size() - 1).cords.add(new Cord(e.getX(), e.getY()));
|
||||||
|
if(shape.equals("line") || shape.equals("rect") || shape.equals("oval") || shape.equals("circle"))
|
||||||
|
{
|
||||||
|
if(parts.get(parts.size() - 1).cords.size() > 1) parts.get(parts.size() - 1).cords.remove(1);
|
||||||
|
parts.get(parts.size() - 1).cords.add(new Cord(e.getX(), e.getY()));
|
||||||
|
}
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
parts.add(new Part(shape, color,isfilled));
|
||||||
|
parts.get(parts.size() - 1).cords.add(new Cord(e.getX(), e.getY()));
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if(shape.equals("pencil")) parts.get(parts.size() - 1).cords.add(new Cord(e.getX(), e.getY()));
|
||||||
|
if(shape.equals("line") || shape.equals("rect") || shape.equals("oval") || shape.equals("circle"))
|
||||||
|
{
|
||||||
|
if(parts.get(parts.size() - 1).cords.size() > 1) parts.get(parts.size() - 1).cords.remove(1);
|
||||||
|
parts.get(parts.size() - 1).cords.add(new Cord(e.getX(), e.getY()));
|
||||||
|
}
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Part
|
||||||
|
{
|
||||||
|
String shape;
|
||||||
|
ArrayList<Cord> cords;
|
||||||
|
Color color;
|
||||||
|
Boolean isfilled;
|
||||||
|
|
||||||
|
public Part()
|
||||||
|
{
|
||||||
|
this.shape = "pencil";
|
||||||
|
this.cords = new ArrayList<>();
|
||||||
|
this.color = Color.black;
|
||||||
|
this.isfilled = false;
|
||||||
|
}
|
||||||
|
public Part(String shape, Color color, Boolean isfilled)
|
||||||
|
{
|
||||||
|
this.shape = shape;
|
||||||
|
this.cords = new ArrayList<>();
|
||||||
|
this.color = color;
|
||||||
|
this.isfilled = isfilled;
|
||||||
|
}
|
||||||
|
public Part(String shape, ArrayList<Cord> cords, Color color, Boolean isfilled)
|
||||||
|
{
|
||||||
|
this.shape = shape;
|
||||||
|
this.cords = cords;
|
||||||
|
this.color = color;
|
||||||
|
this.isfilled = isfilled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cord
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
public Cord(int x, int y)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue