Board=JPanel, Schack=JFrame

This commit is contained in:
lov3b 2022-03-01 18:39:24 +01:00
parent a66a3e625a
commit 2bb09a0f94
7 changed files with 134 additions and 149 deletions

View File

@ -6,19 +6,19 @@
For the purpose of easier reading the script For the purpose of easier reading the script
is divided into following sections: is divided into following sections:
- initialization - initialization
- compilation - compilation
- jar - jar
- execution - execution
- debugging - debugging
- javadoc - javadoc
- test compilation - test compilation
- test execution - test execution
- test debugging - test debugging
- applet - applet
- cleanup - cleanup
--> -->
<project xmlns:if="ant:if" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" xmlns:unless="ant:unless" basedir=".." default="default" name="Schack-impl"> <project xmlns:if="ant:if" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" xmlns:unless="ant:unless" basedir=".." default="default" name="Schack-impl">
<fail message="Please build using Ant 1.8.0 or higher."> <fail message="Please build using Ant 1.8.0 or higher.">
<condition> <condition>
@ -29,10 +29,10 @@ is divided into following sections:
</fail> </fail>
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/> <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
<!-- <!--
====================== ======================
INITIALIZATION SECTION INITIALIZATION SECTION
====================== ======================
--> -->
<target name="-pre-init"> <target name="-pre-init">
<!-- Empty placeholder for easier customization. --> <!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. --> <!-- You can override this target in the ../build.xml file. -->
@ -786,8 +786,8 @@ is divided into following sections:
</target> </target>
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/> <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
<!-- <!--
pre NB7.2 profiling section; consider it deprecated pre NB7.2 profiling section; consider it deprecated
--> -->
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/> <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
<target if="profiler.info.jvmargs.agent" name="-profile-pre-init"> <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
<!-- Empty placeholder for easier customization. --> <!-- Empty placeholder for easier customization. -->
@ -834,8 +834,8 @@ is divided into following sections:
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail> <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
</target> </target>
<!-- <!--
end of pre NB7.2 profiling section end of pre NB7.2 profiling section
--> -->
<target depends="-init-debug-args" name="-init-macrodef-nbjpda"> <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="name"/> <attribute default="${main.class}" name="name"/>
@ -1048,10 +1048,10 @@ is divided into following sections:
</target> </target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/> <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<!-- <!--
=================== ===================
COMPILATION SECTION COMPILATION SECTION
=================== ===================
--> -->
<target name="-deps-jar-init" unless="built-jar.properties"> <target name="-deps-jar-init" unless="built-jar.properties">
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/> <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
<delete file="${built-jar.properties}" quiet="true"/> <delete file="${built-jar.properties}" quiet="true"/>
@ -1124,10 +1124,10 @@ is divided into following sections:
</target> </target>
<target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/> <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
<!-- <!--
==================== ====================
JAR BUILDING SECTION JAR BUILDING SECTION
==================== ====================
--> -->
<target depends="init" name="-pre-pre-jar"> <target depends="init" name="-pre-pre-jar">
<dirname file="${dist.jar}" property="dist.jar.dir"/> <dirname file="${dist.jar}" property="dist.jar.dir"/>
<mkdir dir="${dist.jar.dir}"/> <mkdir dir="${dist.jar.dir}"/>
@ -1257,10 +1257,10 @@ is divided into following sections:
<target depends="init,compile,-pre-jar,-set-module-main-class,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/> <target depends="init,compile,-pre-jar,-set-module-main-class,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/>
<target depends="init,compile,-pre-jar,-do-jar,-post-jar,deploy" description="Build JAR." name="jar"/> <target depends="init,compile,-pre-jar,-do-jar,-post-jar,deploy" description="Build JAR." name="jar"/>
<!-- <!--
================= =================
DEPLOY SECTION DEPLOY SECTION
================= =================
--> -->
<target name="-pre-deploy"> <target name="-pre-deploy">
<!-- Empty placeholder for easier customization. --> <!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. --> <!-- You can override this target in the ../build.xml file. -->
@ -1322,10 +1322,10 @@ is divided into following sections:
</target> </target>
<target depends="-do-jar,-post-jar,-pre-deploy,-do-deploy,-post-deploy" name="deploy"/> <target depends="-do-jar,-post-jar,-pre-deploy,-do-deploy,-post-deploy" name="deploy"/>
<!-- <!--
================= =================
EXECUTION SECTION EXECUTION SECTION
================= =================
--> -->
<target depends="init,compile" description="Run a main class." name="run"> <target depends="init,compile" description="Run a main class." name="run">
<j2seproject1:java> <j2seproject1:java>
<customize> <customize>
@ -1345,10 +1345,10 @@ is divided into following sections:
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/> <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
</target> </target>
<!-- <!--
================= =================
DEBUGGING SECTION DEBUGGING SECTION
================= =================
--> -->
<target depends="init" if="netbeans.home" name="-debug-start-debugger"> <target depends="init" if="netbeans.home" name="-debug-start-debugger">
<j2seproject1:nbjpdastart name="${debug.class}"/> <j2seproject1:nbjpdastart name="${debug.class}"/>
</target> </target>
@ -1386,13 +1386,13 @@ is divided into following sections:
</target> </target>
<target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/> <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
<!-- <!--
================= =================
PROFILING SECTION PROFILING SECTION
================= =================
--> -->
<!-- <!--
pre NB7.2 profiler integration pre NB7.2 profiler integration
--> -->
<target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72"> <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect> <nbprofiledirect>
@ -1445,8 +1445,8 @@ is divided into following sections:
</j2seproject3:junit> </j2seproject3:junit>
</target> </target>
<!-- <!--
end of pre NB72 profiling section end of pre NB72 profiling section
--> -->
<target if="netbeans.home" name="-profile-check"> <target if="netbeans.home" name="-profile-check">
<condition property="profiler.configured"> <condition property="profiler.configured">
<or> <or>
@ -1481,10 +1481,10 @@ is divided into following sections:
<antcall target="run-applet"/> <antcall target="run-applet"/>
</target> </target>
<!-- <!--
=============== ===============
JAVADOC SECTION JAVADOC SECTION
=============== ===============
--> -->
<target depends="init" if="have.sources" name="-javadoc-build"> <target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/> <mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}"> <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
@ -1532,10 +1532,10 @@ is divided into following sections:
</target> </target>
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/> <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
<!-- <!--
========================= =========================
TEST COMPILATION SECTION TEST COMPILATION SECTION
========================= =========================
--> -->
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test"> <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
<mkdir dir="${build.test.classes.dir}"/> <mkdir dir="${build.test.classes.dir}"/>
</target> </target>
@ -1631,10 +1631,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/> <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
<!-- <!--
======================= =======================
TEST EXECUTION SECTION TEST EXECUTION SECTION
======================= =======================
--> -->
<target depends="init" if="have.tests" name="-pre-test-run"> <target depends="init" if="have.tests" name="-pre-test-run">
<mkdir dir="${build.test.results.dir}"/> <mkdir dir="${build.test.results.dir}"/>
</target> </target>
@ -1668,10 +1668,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile-test-single,-init-test-run-module-properties,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/> <target depends="init,compile-test-single,-init-test-run-module-properties,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
<!-- <!--
======================= =======================
TEST DEBUGGING SECTION TEST DEBUGGING SECTION
======================= =======================
--> -->
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test"> <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail> <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/> <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
@ -1692,10 +1692,10 @@ is divided into following sections:
</target> </target>
<target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/> <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
<!-- <!--
========================= =========================
APPLET EXECUTION SECTION APPLET EXECUTION SECTION
========================= =========================
--> -->
<target depends="init,compile-single" name="run-applet"> <target depends="init,compile-single" name="run-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer"> <j2seproject1:java classname="sun.applet.AppletViewer">
@ -1705,10 +1705,10 @@ is divided into following sections:
</j2seproject1:java> </j2seproject1:java>
</target> </target>
<!-- <!--
========================= =========================
APPLET DEBUGGING SECTION APPLET DEBUGGING SECTION
========================= =========================
--> -->
<target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet"> <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer"> <j2seproject3:debug classname="sun.applet.AppletViewer">
@ -1719,10 +1719,10 @@ is divided into following sections:
</target> </target>
<target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/> <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
<!-- <!--
=============== ===============
CLEANUP SECTION CLEANUP SECTION
=============== ===============
--> -->
<target name="-deps-clean-init" unless="built-clean.properties"> <target name="-deps-clean-init" unless="built-clean.properties">
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/> <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
<delete file="${built-clean.properties}" quiet="true"/> <delete file="${built-clean.properties}" quiet="true"/>

View File

@ -1,9 +1,18 @@
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Schack
application.vendor=love
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent=true
build.classes.dir=${build.dir}/classes build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned: # This directory is removed when the project is cleaned:
@ -30,6 +39,7 @@ dist.archive.excludes=
dist.dir=dist dist.dir=dist
dist.jar=${dist.dir}/Schack.jar dist.jar=${dist.dir}/Schack.jar
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes= excludes=
includes=** includes=**
jar.compress=false jar.compress=false
@ -54,6 +64,7 @@ javac.test.processorpath=\
javadoc.additionalparam= javadoc.additionalparam=
javadoc.author=false javadoc.author=false
javadoc.encoding=${source.encoding} javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false javadoc.noindex=false
javadoc.nonavbar=false javadoc.nonavbar=false
javadoc.notree=false javadoc.notree=false
@ -62,6 +73,8 @@ javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
jlink.launcher=false
jlink.launcher.name=Schack
main.class=schack.Schack main.class=schack.Schack
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF

View File

@ -5,57 +5,33 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
public class Board extends JFrame public class Board extends JPanel {
{
ArrayList<Piece> pieces = new ArrayList<>(); ArrayList<Piece> pieces = new ArrayList<>();
public Board() public Board() {
{ setPreferredSize(new Dimension(800, 800));
setTitle("Schack");
setAlwaysOnTop(true);
setResizable(false);
setContentPane(cp);
cp.setPreferredSize(new Dimension(800, 800) );
pack();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} }
JPanel cp = new JPanel() public void paintComponent(Graphics g) {
{ Graphics2D g2 = (Graphics2D) g;
public void paintComponent(Graphics g) g2.scale(100, 100);
{ g2.setBackground(Color.WHITE);
Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.BLACK);
g2.scale(100, 100); for (int i = 0; i < 8; i += 2) {
g2.setBackground(Color.WHITE); for (int j = 0; j < 8; j += 2) {
g2.setColor(Color.BLACK); g.fillRect(i, j, 1, 1);
for (int i = 0; i < 8; i += 2) {
for (int j = 0; j < 8; j += 2) {
g.fillRect(i, j, 1, 1);
}
}
for (int i = 1; i < 8; i += 2) {
for (int j = 1; j < 8; j += 2) {
g.fillRect(i, j, 1, 1);
}
} }
} }
};
// for(Piece p : pieces){
// p.draw();
// }
public static void main(String[] args) for (int i = 1; i < 8; i += 2) {
{ for (int j = 1; j < 8; j += 2) {
new Board(); g.fillRect(i, j, 1, 1);
}
}
} }
} }

View File

@ -9,8 +9,8 @@ package schack;
* *
* @author lovbil251 * @author lovbil251
*/ */
public interface DiagonalWalk public interface DiagonalWalk {
{
public void walDiagonal(); public void walDiagonal();
} }

View File

@ -1,6 +1,8 @@
package schack; package schack;
public final class King extends Piece{ public final class King extends Piece {
public boolean isSeen(){return true;} public boolean isSeen() {
return true;
}
} }

View File

@ -4,13 +4,14 @@ import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
public class Piece { public class Piece {
public Point position;
public boolean isValidMove(Point p, ArrayList<Piece> pieces){return true;}
void draw() public Point position;
{
public boolean isValidMove(Point p, ArrayList<Piece> pieces) {
return true;
}
void draw() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }

View File

@ -1,35 +1,28 @@
package schack; package schack;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame; import javax.swing.JFrame;
/** /**
* *
* @author Love Billenius & Simon Hansson * @author Love Billenius & Simon Hansson
*/ */
public class Schack extends JFrame public class Schack extends JFrame {
{
public Dimension size = new Dimension(800, 800); public Dimension size = new Dimension(800, 800);
public Schack() public Schack() {
{ setTitle("Schack");
setSize(size);
setAlwaysOnTop(true); setAlwaysOnTop(true);
setBackground(Color.black); setResizable(false);
setContentPane(new Board());
pack();
setVisible(true); setVisible(true);
} setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
private void drawSquares(Graphics g){
} }
public static void main(String[] args) public static void main(String[] args) {
{
new Schack(); new Schack();
} }