commit 558139141cc9d6332381b9484e2eb94eb04338e2 Author: ThirstyShark Date: Thu Jan 31 16:28:32 2019 -0600 initial commit diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..47349fb --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project CancerGrowth. + + + diff --git a/build/built-jar.properties b/build/built-jar.properties new file mode 100644 index 0000000..f93c3f5 --- /dev/null +++ b/build/built-jar.properties @@ -0,0 +1,4 @@ +#Wed, 30 Jan 2019 20:03:25 -0600 + + +C\:\\Users\\cd109\\Desktop\\apcs\\Projects\\chapter-03\\CancerGrowth= diff --git a/build/classes/cancergrowth/CancerGrowth$1.class b/build/classes/cancergrowth/CancerGrowth$1.class new file mode 100644 index 0000000..7e42cea Binary files /dev/null and b/build/classes/cancergrowth/CancerGrowth$1.class differ diff --git a/build/classes/cancergrowth/CancerGrowth.class b/build/classes/cancergrowth/CancerGrowth.class new file mode 100644 index 0000000..94cd7f0 Binary files /dev/null and b/build/classes/cancergrowth/CancerGrowth.class differ diff --git a/build/classes/cancergrowth/Cell.class b/build/classes/cancergrowth/Cell.class new file mode 100644 index 0000000..e28ed90 Binary files /dev/null and b/build/classes/cancergrowth/Cell.class differ diff --git a/build/classes/cancergrowth/CellPanel$1.class b/build/classes/cancergrowth/CellPanel$1.class new file mode 100644 index 0000000..997095b Binary files /dev/null and b/build/classes/cancergrowth/CellPanel$1.class differ diff --git a/build/classes/cancergrowth/CellPanel$2.class b/build/classes/cancergrowth/CellPanel$2.class new file mode 100644 index 0000000..63d521b Binary files /dev/null and b/build/classes/cancergrowth/CellPanel$2.class differ diff --git a/build/classes/cancergrowth/CellPanel.class b/build/classes/cancergrowth/CellPanel.class new file mode 100644 index 0000000..dac5298 Binary files /dev/null and b/build/classes/cancergrowth/CellPanel.class differ diff --git a/build/classes/cancergrowth/ComboBoxRenderer.class b/build/classes/cancergrowth/ComboBoxRenderer.class new file mode 100644 index 0000000..28bda25 Binary files /dev/null and b/build/classes/cancergrowth/ComboBoxRenderer.class differ diff --git a/build/classes/cancergrowth/createImage.class b/build/classes/cancergrowth/createImage.class new file mode 100644 index 0000000..4a637ed Binary files /dev/null and b/build/classes/cancergrowth/createImage.class differ diff --git a/build/classes/cancergrowth/main.class b/build/classes/cancergrowth/main.class new file mode 100644 index 0000000..820a041 Binary files /dev/null and b/build/classes/cancergrowth/main.class differ diff --git a/build/classes/cancergrowth/main2.class b/build/classes/cancergrowth/main2.class new file mode 100644 index 0000000..d8e3bc5 Binary files /dev/null and b/build/classes/cancergrowth/main2.class differ diff --git a/dist/CancerGrowth.jar b/dist/CancerGrowth.jar new file mode 100644 index 0000000..3d7f47f Binary files /dev/null and b/dist/CancerGrowth.jar differ diff --git a/dist/README.TXT b/dist/README.TXT new file mode 100644 index 0000000..d68f376 --- /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 "CancerGrowth.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/dist/lib/swing-layout-1.0.4.jar b/dist/lib/swing-layout-1.0.4.jar new file mode 100644 index 0000000..f722841 Binary files /dev/null and b/dist/lib/swing-layout-1.0.4.jar differ 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..41e13ea --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..bca8107 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=fac1c412 +build.xml.script.CRC32=cb6c7ccd +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=fac1c412 +nbproject/build-impl.xml.script.CRC32=0dd90c6f +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.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..14fa042 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=false +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\cd109\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..ccc134e --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,11 @@ + + + + + + file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/CellPanel.java + file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/CancerGrowth.java + file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/Cell.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..f3c531f --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,77 @@ +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=CancerGrowth +application.vendor=cd109 +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}/CancerGrowth.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath=\ + ${libs.swing-layout.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= +main.class=cancergrowth.CancerGrowth +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..3a5dd8e --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + CancerGrowth + + + + + + + + + diff --git a/src/cancergrowth/CancerGrowth.java b/src/cancergrowth/CancerGrowth.java new file mode 100644 index 0000000..be92bff --- /dev/null +++ b/src/cancergrowth/CancerGrowth.java @@ -0,0 +1,29 @@ +package cancergrowth; + +/* + * File Name: CancerGrowth.java + * Created: Oct 4, 2017 + */ + +public class CancerGrowth extends javax.swing.JFrame +{ + //Constructor code for the frame + public CancerGrowth(String s) + { + super(s); + super.setContentPane(new CellPanel()); + super.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); + super.setLocation(50, 50); + super.setResizable(false); + super.pack(); + } + + // + public static void main(String[] args) + { + javax.swing.JFrame.setDefaultLookAndFeelDecorated(false); + java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CancerGrowth("Cancer Simulation").setVisible(true); } } ); + } + // + +} diff --git a/src/cancergrowth/Cell.java b/src/cancergrowth/Cell.java new file mode 100644 index 0000000..27a7a6a --- /dev/null +++ b/src/cancergrowth/Cell.java @@ -0,0 +1,139 @@ +package cancergrowth; + +import java.awt.Color; +import java.awt.Image; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.lang.Math; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Scanner; +/* + * File Name: Cell.java + * Created: Nov 7, 2018 + * Author: + */ + + +public class Cell extends Object +{ + + private int xval; + private int yval; + private Color myColor; + private ArrayList stages = new ArrayList(); + private int currentStage; + private int currentTime; + public Cell(int x, int y, Color C) + { + xval = x; + yval = y; + myColor = C; + stages.add(10 + (int) (Math.random() * 3 - 1)); + stages.add(6 + (int) (Math.random() * 3 - 1)); + stages.add(3 + (int) (Math.random() * 3 - 1)); + stages.add(1 + (int) (Math.random() * 2)); + currentTime = 0; + currentStage = 0; + } + @Override + public String toString() + { + return "(" + xval + ", " + yval + ")"; + } + + public int getX() + { + return xval; + } + + public int getY() + { + return yval; + } + + public Color getColor() + { + return myColor; + } + + public int moveTo(int x, int y) + { + xval = x; + yval = y; + return 0; + } + public Cell performTime() { + this.currentTime ++; + Cell newcell = this; + //System.out.println("Increased Current Time to:" + this.currentTime); + if(this.currentTime > stages.get(this.currentStage)) { + if(currentStage == 3) { + // SPLIT + int width = (int) (-50 + Math.random()*101); + int height = (int) (-50 + Math.random()*101); + while (width < 20 && width > -20) width = (int) (-50 + Math.random()*101); + while (height < 20 && height > -20) height = (int) (-50 + Math.random()*101); + newcell = new Cell(xval + width, yval + height, new Color(255, 0, 0, 100)); + //stages = new ArrayList(); + //stages.add(10 + (int) Math.random() * 3 - 1); + //stages.add(7 + (int) Math.random() * 3 - 1); + //stages.add(3 + (int) Math.random() * 3 - 1); + //stages.add(1 + (int) Math.random() * 2); + + xval -= width; + yval -= height; + currentStage = 0; + currentTime = 1; + myColor = new Color(255, 0, 0, 100); + } + else { + this.currentStage ++; + this.currentTime = 0; + if(currentStage == 1) myColor = new Color(255, 255, 0, 100); + if(currentStage == 2) myColor = new Color(0, 255, 0, 100); + if(currentStage == 3) myColor = new Color(0, 0, 255, 100); + } + } + return newcell; + } + + public Image getImage() + { + Image canvas = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB); + Graphics g = canvas.getGraphics(); + + g.setColor(this.getColor()); + + int width = 50; + int pos = 0; + if (currentStage == 0) { + width = (int) ((currentTime + 1) * 2 + 22.5); + pos = (50 - width) / 2; + } + g.fillOval(pos, pos, width, width); + g.setColor(Color.BLACK); + g.drawOval(pos, pos, width, width); + StringBuilder x = new StringBuilder(""); + if(currentStage == 0) x.append("G1"); + if(currentStage == 1) x.append("S"); + if(currentStage == 2) x.append("G2"); + if(currentStage == 3) x.append("M"); + g.drawString(x.toString(), 20, 30); + return canvas; + } + + public Cell clone(int x, int y) + { + Cell out = new Cell(x, y, getColor()); + return out; + } + public Cell combine(Cell in) { + int r = (this.getColor().getRed() + in.getColor().getRed()) / 2; + int g = (this.getColor().getGreen() + in.getColor().getGreen()) / 2; + int b = (this.getColor().getBlue() + in.getColor().getBlue()) / 2; + Cell out = new Cell((in.getX() + this.getX())/2, (in.getY() + this.getY())/2, new Color(r, g, b)); + return out; + } +} diff --git a/src/cancergrowth/CellPanel.form b/src/cancergrowth/CellPanel.form new file mode 100644 index 0000000..4de91e3 --- /dev/null +++ b/src/cancergrowth/CellPanel.form @@ -0,0 +1,79 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cancergrowth/CellPanel.java b/src/cancergrowth/CellPanel.java new file mode 100644 index 0000000..4cf3128 --- /dev/null +++ b/src/cancergrowth/CellPanel.java @@ -0,0 +1,218 @@ +package cancergrowth; + +/** + * File Name: CellPanel.java + * Created: Oct 02, 2017 + * Author: + */ +import java.util.*; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import javax.swing.Timer; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +public class CellPanel extends javax.swing.JPanel implements ActionListener, ChangeListener +{ + private Timer swingTimer; + //private JButton go; + //private JSlider speed; + private int delay; + private boolean growing = false; + int count = 0; + long time0 = System.nanoTime(); + long time1 = time0; + private boolean draw = false; + + ArrayList cells = new ArrayList(); + + Graphics g2; + Image canvas; + + public CellPanel() + { + + super(); + this.initComponents(); + + //Cell t1 = new Cell(300, 100, Color.RED); + //choice1.addItem(t1); + //cells.add(t1); + Cell t2 = new Cell(475, 475, new Color(255, 0, 0, 100)); + //choice1.addItem(t2); + cells.add(t2); + //choice2.addItem(t2); + + //choice1.setRenderer(new ComboBoxRenderer()); + //choice2.setRenderer(new ComboBoxRenderer()); + speed.setValue(250); + delay = speed.getValue(); + swingTimer = new Timer(delay, this); + //swingTimer.start(); + } + + @Override + public void actionPerformed(ActionEvent e) + { + time1 = System.nanoTime() - time0; + time0 = System.nanoTime(); + if (swingTimer.isRunning()) + { + speed.setEnabled(true); + //go.setText("Play "); + //swingTimer.stop(); + } + else + { + speed.setEnabled(false); + swingTimer.start(); + } + + //canvas = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB); + //g2 = canvas.getGraphics(); + for (int k = 0; k < cells.size(); k++) + { + Cell t = cells.get(k); + Cell rec = t.performTime(); + if (t != rec) { + cells.add(rec); + } + //g2.drawImage(t.getImage(), t.getX(), t.getY(), this); + } + growing = true; + count ++; + //System.out.println("ACTION PERFORMED"); + super.repaint(); + + } + @Override + public void stateChanged(ChangeEvent ce) + { + delay = speed.getValue(); + } + + @Override + public void paintComponent(Graphics g) + { + super.paintComponent(g); + //g.setColor(Color.BLACK); + + + int x = cells.size() - 1; + //g.drawImage(canvas, 0, 0, this); + for (int k = x; k >= 0; k--) + { + Cell t = cells.get(k); + /*if(k > cells.size() / 4) { + g.setColor(t.getColor()); + g.fillOval(t.getX(), t.getY(), 50, 50); + } else*/ + //if (draw || cells.size() > 100000000) { + g.drawImage(t.getImage(), t.getX(), t.getY(), this); + //swingTimer.stop(); + //} + } + + jLabel1.setText("Delay: " + delay + "ms. Hours since start: " + count + ". Cell Count: " + cells.size()); + //System.out.println("Speed: " + (int) (delay / (time1 / 100000000.0)) + "%"); + growing = false; + } + + + + /** This method is called from within the constructor to initialize the form. + * + * WARNING: Do NOT modify this code by hand. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() + { + + speed = new javax.swing.JSlider(); + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + + speed.setMaximum(1000); + speed.setMinimum(1); + speed.setPaintLabels(true); + speed.setPaintTicks(true); + speed.setSnapToTicks(true); + speed.addMouseListener(new java.awt.event.MouseAdapter() + { + public void mouseReleased(java.awt.event.MouseEvent evt) + { + speedMouseReleased(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N + jLabel1.setText("Delay:"); + + jButton1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + jButton1.setText("Start"); + jButton1.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + jButton1ActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(speed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jLabel1) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 662, Short.MAX_VALUE) + .add(jButton1) + .add(18, 18, 18)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .add(jLabel1)) + .add(org.jdesktop.layout.GroupLayout.LEADING, speed, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(967, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void speedMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_speedMouseReleased + {//GEN-HEADEREND:event_speedMouseReleased + // TODO add your handling code here: + delay = speed.getValue(); + //swingTimer.setDelay(1000); + super.repaint(); + }//GEN-LAST:event_speedMouseReleased + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed + {//GEN-HEADEREND:event_jButton1ActionPerformed + // TODO add your handling code here: + swingTimer.setDelay(delay); + swingTimer.start(); + + }//GEN-LAST:event_jButton1ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JSlider speed; + // End of variables declaration//GEN-END:variables + +}