-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from jcksndfrd/feature/timeanddate
Time and date feature, resolves #22
- Loading branch information
Showing
4 changed files
with
45 additions
and
7 deletions.
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
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 |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package nz.ac.massey.cs.flackpad; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JTextArea; | ||
import javax.swing.text.BadLocationException; | ||
|
||
@SuppressWarnings("serial") | ||
class TextArea extends JTextArea { | ||
|
||
Window window; | ||
|
||
TextArea(Window window) { | ||
super(); | ||
this.window = window; | ||
this.setBorder(BorderFactory.createCompoundBorder(this.getBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); | ||
this.getDocument().addDocumentListener(new DocListener(window)); | ||
} | ||
|
||
void addTimeAndDate() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm dd/MM/yyyy"); | ||
try { | ||
this.getDocument().insertString(0, formatter.format(LocalDateTime.now()) + "\n", null); | ||
} catch (BadLocationException e) { | ||
Dialogs.error("Something went wrong when getting the time and date", window); | ||
} | ||
} | ||
|
||
} |
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