Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jonathan Hector
5,225 PointsWorking on a Project but can' t see why is it not working. Creates rectangles underneath each other.
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor. */ package rectangleproject;
/**
- import the necessary packages / import java.awt.Font; import javafx.application.Application; import javafx.scene.; import javafx.stage.; import javafx.scene.Group; import javafx.scene.paint.; import javafx.scene.shape.*; import javafx.scene.text.Text;
/** *
- @author jonathanhector *
-
creates the scene and scene Title * */ public abstract class RectangleProject extends Application {
private Shape rect1; private Shape rect2; Group secondaryGroup = new Group(rect1, rect2); private Object shapeBehavior;
private void setScene(Stage stage) { Group rootNode = new Group(); Scene scene = new Scene(rootNode, 600, 800);
/** * Creates the rectangles and gives it its dimensions. This part fills * the rectangles with Light Grey color. */ rect1 = new Rectangle(10, 10, 40, 50); rect1.setFill(Color.LIGHTGREY); rect1.setStroke(Color.WHITE); rect2 = new Rectangle(20, 35, 40, 50); rect2.setFill(Color.LIGHTGREY); rect2.setStroke(Color.WHITE); /** * call the new scene and creates the rect1 and rect2 */ secondaryGroup.getChildren().add(rect1); secondaryGroup.getChildren().add(rect2); rootNode.getChildren().add(secondaryGroup); stage.setScene(scene); stage.setTitle("Two Rectangles Not Behaving!!!"); stage.show();
}
/**
- determines the behavior of the rectangles */
private void shapeBehavior(){
Shape rect3 = Shape.union(rect1,rect2); rect3.setFill(Color.YELLOWGREEN); rect3 = Shape.intersect(rect1,rect2); rect3.setFill(Color.VIOLET); rect3 = Shape.subtract(rect1,rect2); rect3.setFill(Color.ORANGE);
}
/** *
- @return the header for each diagram */
public String header() {
Text title1 = new Text(20, 5, "Sets intersection"); title1.setFont(new Font(24)); title1.setTextOrigin(VPos.TOP); rootNode.getChildren().add(title1); Text title2 = new Text(20, 5, "Sets union"); title2.setFont(new Font(24)); title2.setTextOrigin(VPos.MIDDLE); rootNode.getChildren().add(title2); Text title3 = new Text(20, 5, "Sets symmetrical difference"); title3.setFont(new Font(24)); title3.setTextOrigin(VPos.BOTTOM); rootNode.getChildren().add(title3);
}
public static void main(String[] args) {
Application.launch(args);}
}