mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 12:50:10 +01:00
Board=JPanel, Schack=JFrame
This commit is contained in:
parent
a66a3e625a
commit
2bb09a0f94
@ -6,19 +6,19 @@
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- test compilation
|
||||
- test execution
|
||||
- test debugging
|
||||
- applet
|
||||
- cleanup
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- test compilation
|
||||
- test execution
|
||||
- test debugging
|
||||
- applet
|
||||
- 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">
|
||||
<fail message="Please build using Ant 1.8.0 or higher.">
|
||||
<condition>
|
||||
@ -29,10 +29,10 @@ is divided into following sections:
|
||||
</fail>
|
||||
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
@ -786,8 +786,8 @@ is divided into following sections:
|
||||
</target>
|
||||
<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 if="profiler.info.jvmargs.agent" name="-profile-pre-init">
|
||||
<!-- 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>
|
||||
</target>
|
||||
<!--
|
||||
end of pre NB7.2 profiling section
|
||||
-->
|
||||
end of pre NB7.2 profiling section
|
||||
-->
|
||||
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${main.class}" name="name"/>
|
||||
@ -1048,10 +1048,10 @@ is divided into following sections:
|
||||
</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"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="-deps-jar-init" unless="built-jar.properties">
|
||||
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
|
||||
<delete file="${built-jar.properties}" quiet="true"/>
|
||||
@ -1124,10 +1124,10 @@ is divided into following sections:
|
||||
</target>
|
||||
<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">
|
||||
<dirname file="${dist.jar}" property="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,-do-jar,-post-jar,deploy" description="Build JAR." name="jar"/>
|
||||
<!--
|
||||
=================
|
||||
DEPLOY SECTION
|
||||
=================
|
||||
-->
|
||||
=================
|
||||
DEPLOY SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-pre-deploy">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
@ -1322,10 +1322,10 @@ is divided into following sections:
|
||||
</target>
|
||||
<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">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
@ -1345,10 +1345,10 @@ is divided into following sections:
|
||||
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="init" if="netbeans.home" name="-debug-start-debugger">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
@ -1386,13 +1386,13 @@ is divided into following sections:
|
||||
</target>
|
||||
<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">
|
||||
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
@ -1445,8 +1445,8 @@ is divided into following sections:
|
||||
</j2seproject3:junit>
|
||||
</target>
|
||||
<!--
|
||||
end of pre NB72 profiling section
|
||||
-->
|
||||
end of pre NB72 profiling section
|
||||
-->
|
||||
<target if="netbeans.home" name="-profile-check">
|
||||
<condition property="profiler.configured">
|
||||
<or>
|
||||
@ -1481,10 +1481,10 @@ is divided into following sections:
|
||||
<antcall target="run-applet"/>
|
||||
</target>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<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 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">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
@ -1631,10 +1631,10 @@ is divided into following sections:
|
||||
</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"/>
|
||||
<!--
|
||||
=======================
|
||||
TEST EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
=======================
|
||||
TEST EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init" if="have.tests" name="-pre-test-run">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
@ -1668,10 +1668,10 @@ is divided into following sections:
|
||||
</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"/>
|
||||
<!--
|
||||
=======================
|
||||
TEST DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
=======================
|
||||
TEST DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<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>
|
||||
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
|
||||
@ -1692,10 +1692,10 @@ is divided into following sections:
|
||||
</target>
|
||||
<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">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
@ -1705,10 +1705,10 @@ is divided into following sections:
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<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>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
@ -1719,10 +1719,10 @@ is divided into following sections:
|
||||
</target>
|
||||
<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">
|
||||
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
|
||||
<delete file="${built-clean.properties}" quiet="true"/>
|
||||
|
@ -1,9 +1,18 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processor.options=
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
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.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@ -30,6 +39,7 @@ dist.archive.excludes=
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/Schack.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=false
|
||||
@ -54,6 +64,7 @@ javac.test.processorpath=\
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.html5=false
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
@ -62,6 +73,8 @@ javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jlink.launcher=false
|
||||
jlink.launcher.name=Schack
|
||||
main.class=schack.Schack
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
|
@ -5,57 +5,33 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Board extends JFrame
|
||||
{
|
||||
|
||||
public class Board extends JPanel {
|
||||
|
||||
ArrayList<Piece> pieces = new ArrayList<>();
|
||||
|
||||
public Board()
|
||||
{
|
||||
setTitle("Schack");
|
||||
setAlwaysOnTop(true);
|
||||
setResizable(false);
|
||||
setContentPane(cp);
|
||||
cp.setPreferredSize(new Dimension(800, 800) );
|
||||
pack();
|
||||
setVisible(true);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
public Board() {
|
||||
setPreferredSize(new Dimension(800, 800));
|
||||
}
|
||||
|
||||
JPanel cp = new JPanel()
|
||||
{
|
||||
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
g2.scale(100, 100);
|
||||
g2.setBackground(Color.WHITE);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
g2.scale(100, 100);
|
||||
g2.setBackground(Color.WHITE);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
for (int i = 0; i < 8; i += 2) {
|
||||
for (int j = 0; j < 8; j += 2) {
|
||||
g.fillRect(i, j, 1, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
// for(Piece p : pieces){
|
||||
// p.draw();
|
||||
// }
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Board();
|
||||
for (int i = 1; i < 8; i += 2) {
|
||||
for (int j = 1; j < 8; j += 2) {
|
||||
g.fillRect(i, j, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ package schack;
|
||||
*
|
||||
* @author lovbil251
|
||||
*/
|
||||
public interface DiagonalWalk
|
||||
{
|
||||
public interface DiagonalWalk {
|
||||
|
||||
public void walDiagonal();
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package schack;
|
||||
|
||||
public final class King extends Piece{
|
||||
public final class King extends Piece {
|
||||
|
||||
public boolean isSeen(){return true;}
|
||||
public boolean isSeen() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,14 @@ import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
|
@ -1,35 +1,28 @@
|
||||
package schack;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Love Billenius & Simon Hansson
|
||||
*/
|
||||
public class Schack extends JFrame
|
||||
{
|
||||
public class Schack extends JFrame {
|
||||
|
||||
public Dimension size = new Dimension(800, 800);
|
||||
|
||||
public Schack()
|
||||
{
|
||||
setSize(size);
|
||||
public Schack() {
|
||||
setTitle("Schack");
|
||||
setAlwaysOnTop(true);
|
||||
setBackground(Color.black);
|
||||
|
||||
setResizable(false);
|
||||
setContentPane(new Board());
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void drawSquares(Graphics g){
|
||||
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
new Schack();
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user