From 354a7aa455a016ac179d7f027014e6b9c2a2433a Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 12 Feb 2011 13:04:41 +0000 Subject: Added parameter box for adding objects. The chainlink is not implemented yet as its params are very different. --- src/tesseract/menuitems/PlanarPolygonMenuItem.java | 39 ++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/tesseract/menuitems/PlanarPolygonMenuItem.java') diff --git a/src/tesseract/menuitems/PlanarPolygonMenuItem.java b/src/tesseract/menuitems/PlanarPolygonMenuItem.java index a41dabb..6759f19 100644 --- a/src/tesseract/menuitems/PlanarPolygonMenuItem.java +++ b/src/tesseract/menuitems/PlanarPolygonMenuItem.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; import javax.swing.JColorChooser; @@ -14,6 +15,7 @@ import javax.vecmath.Color3f; import javax.vecmath.Vector3f; import tesseract.World; +import tesseract.objects.Ellipsoid; import tesseract.objects.PlanarPolygon; /** @@ -48,27 +50,36 @@ public class PlanarPolygonMenuItem extends TesseractMenuItem { //If the default button is checked, the frame will close. final JCheckBox defaultButton = getDefaultButton(); final JFrame params = getParamFrame(); + final JButton enterButton = getEnterButton(); defaultButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent ev) { if (defaultButton.isSelected()) { - myWorld.addObject(new PlanarPolygon(new Vector3f(0f,-.3f, 0f), getDefaultRadius())); + myWorld.addObject(new PlanarPolygon(getDefaultPosition(), getDefaultRadius())); params.dispose(); } } }); - - /*if(arg0. == true) { - myWorld.addObject(new PlanarPolygon(new Vector3f(0,0,0), DEFAULT_RADIUS)); - params.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - }*/ - - /*Vector3f pos = - parseVector(JOptionPane.showInputDialog("Enter the position")); - float radius = - Float.parseFloat(JOptionPane.showInputDialog("Enter the radius")); - - myWorld.addObject(new PlanarPolygon(pos, radius));*/ + enterButton.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent event) { + String string = getPositionField().getText(); + Vector3f pos = parseVector(string); + setPosition(pos); + + String string2 = getRadiusField().getText(); + float radius = Float.parseFloat(string2); + setRadius(radius); + + String string3 = getMassField().getText(); + float mass = Float.parseFloat(string3); + setMass(mass); + + if (event.getSource() == enterButton) { + myWorld.addObject(new Ellipsoid(getPosition(), getRadius())); + params.dispose(); + } + } + }); } } -- cgit v1.2.3