forked from nus-cs2103-AY2223S2/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duke Level 10: Completeing JavaFX Tutorial
- Loading branch information
Showing
6 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package duke; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.layout.HBox; | ||
|
||
public class DialogBox extends HBox { | ||
|
||
private Label text; | ||
private ImageView displayPicture; | ||
|
||
public DialogBox(Label l, ImageView iv) { | ||
text = l; | ||
displayPicture = iv; | ||
|
||
text.setWrapText(true); | ||
displayPicture.setFitWidth(100.0); | ||
displayPicture.setFitHeight(100.0); | ||
|
||
this.setAlignment(Pos.TOP_RIGHT); | ||
this.getChildren().addAll(text, displayPicture); | ||
} | ||
|
||
/** | ||
* Flips the dialog box such that the ImageView is on the left and text on the right. | ||
*/ | ||
private void flip() { | ||
this.setAlignment(Pos.TOP_LEFT); | ||
ObservableList<Node> tmp = FXCollections.observableArrayList(this.getChildren()); | ||
FXCollections.reverse(tmp); | ||
this.getChildren().setAll(tmp); | ||
} | ||
|
||
public static DialogBox getUserDialog(Label l, ImageView iv) { | ||
return new DialogBox(l, iv); | ||
} | ||
|
||
public static DialogBox getDukeDialog(Label l, ImageView iv) { | ||
var db = new DialogBox(l, iv); | ||
db.flip(); | ||
return db; | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package duke; | ||
|
||
import javafx.application.Application; | ||
|
||
/** | ||
* A launcher class to workaround classpath issues. | ||
*/ | ||
public class Launcher { | ||
public static void main(String[] args) { | ||
Application.launch(Duke.class, args); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.