Last active
March 4, 2018 19:34
-
-
Save jacobdanovitch/0805e64930f576511cfb7fe2d14d8171 to your computer and use it in GitHub Desktop.
Week4_Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.scene.control.*; | |
import javafx.scene.layout.Pane; | |
import javafx.scene.layout.BorderPane; | |
public class StickyNote extends BorderPane{ | |
String noteStyle = "-fx-text-fill: black; -fx-background-color: white; -fx-border-color: black;"; | |
String textFieldStyle = "-fx-text-overrun: ellipsis; -fx-background-color: transparent; -fx-border: gone;"; | |
String text = "Your text here..."; | |
String title = "Title"; | |
double titleSize = 12; | |
Pane noteTitle, noteText; | |
public StickyNote(){ | |
setStyle(noteStyle); | |
setPrefSize(200,200); | |
Pane noteTitle = titlePane(); | |
Pane noteText = textPane(); | |
setTop(noteTitle); | |
setCenter(noteText); | |
//getChildren().addAll(noteTitle, noteText); | |
} | |
public Pane titlePane(){ | |
Pane noteTitle = new Pane(); | |
noteTitle.setPrefWidth(200); | |
noteTitle.setStyle("-fx-border-width: 0 0 1 0; -fx-border-color: black; -fx-padding: 2 0 2 0;"); | |
TextField titleText = new TextField(title); | |
titleText.setStyle(String.format("-fx-font-size: %.0fpt; "+textFieldStyle,titleSize)); | |
titleText.setPrefWidth(190); | |
noteTitle.getChildren().addAll(titleText); | |
return noteTitle; | |
} | |
public Pane textPane(){ | |
Pane noteText = new Pane(); | |
TextArea bodyText = new TextArea(text); | |
bodyText.setStyle(textFieldStyle); | |
bodyText.setPrefSize(190,145); | |
noteText.getChildren().addAll(bodyText); | |
return noteText; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.event.EventHandler; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Label; | |
import javafx.scene.input.MouseButton; | |
import javafx.scene.input.MouseEvent; | |
import javafx.scene.layout.BorderPane; | |
import javafx.scene.layout.GridPane; | |
import javafx.scene.layout.Pane; | |
import javafx.stage.Stage; | |
public class StickyNoteApp extends Application { | |
Pane[][] notelist; | |
int rows = 2; | |
int cols = 3; | |
GridPane notepad; | |
BorderPane outer = new BorderPane(); | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) { | |
notepad = new GridPane(); | |
notepad.setStyle("-fx-background-color: #cac8ca"); | |
notelist = new Pane[rows][cols]; | |
for (int i = 0; i < rows; i++) { | |
for (int j = 0; j < cols; j++) { | |
Pane p = new Pane(); | |
p.setOnMouseClicked(new EventHandler<MouseEvent>() { | |
public void handle(MouseEvent e) { | |
StickyNote sticky = new StickyNote(); | |
sticky.getClose().setOnMouseClicked(new EventHandler<MouseEvent>() { | |
@Override | |
public void handle(MouseEvent event) { | |
((Pane)e.getSource()).getChildren().remove(sticky); | |
} | |
}); | |
((Pane)e.getSource()).getChildren().add(sticky); | |
} | |
}); | |
p.setPrefSize(200,200); | |
notepad.add(p,i,j); | |
} | |
} | |
outer.setCenter(notepad); | |
primaryStage.setScene(new Scene(outer)); | |
primaryStage.setTitle("Google Keep v2"); | |
primaryStage.show(); | |
} | |
public void movePane(Pane p1, Pane p2){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment