Código HTML:
do { //Scene theScene = theWindow.getScene(); RadioButtonGroup directionType = new RadioButtonGroup(); BRadioButton up = new BRadioButton("Up", false, directionType); BRadioButton down = new BRadioButton("Down", false, directionType); BRadioButton left = new BRadioButton("Left", false, directionType); BRadioButton right = new BRadioButton("Right", false, directionType); GridContainer directional = new GridContainer(2, 2); directional.setDefaultLayout(new LayoutInfo(LayoutInfo.WEST, LayoutInfo.NONE, new Insets(2, 2, 2, 2), null)); directional.add(up, 0, 0); directional.add(down, 0, 1); directional.add(left, 1, 0); directional.add(right, 1, 1); ValueField vertexValueField = new ValueField(45, ValueField.NONNEGATIVE); ValueField radiusValueField = new ValueField(1.0, ValueField.NONNEGATIVE); ValueField maxErrorValueField = new ValueField(0.05, ValueField.NONNEGATIVE); ValueField directionValueField = new ValueField(0.0, ValueField.NONNEGATIVE); ComponentsDialog dlg = new ComponentsDialog(theFrame, "TearDrop Tool" , new Widget [] { directional, directionValueField, vertexValueField, radiusValueField, maxErrorValueField }, new String [] { "Orientation about z-axis: ", "or specific rotation about z-axis (degrees): ", "Vertex angle (degrees): ", "Radius: ", "Max error: " } ); if (!dlg.clickedOk()) return; double theta = vertexValueField.getValue() / 180 * Math.PI; double radius = radiusValueField.getValue(); double maxError = maxErrorValueField.getValue(); double directionAngle = directionValueField.getValue() / 180 * Math.PI; double errorAngle = Math.acos((radius - maxError) / radius); // inverse cosine double[B] numberSides [/B]= Math.ceil(((2 * Math.PI) - 2 * (Math.PI / 2 - theta)) / errorAngle); // rounded up if (numberSides <= 10) new MessageDialog(theFrame, "Please decrease the value of the maximum error"); } while ([B]numberSides [/B]< 10);