Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
ScheduLearn
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nils Vreman
ScheduLearn
Commits
a73b5ad9
Commit
a73b5ad9
authored
6 years ago
by
Nils Vreman
Browse files
Options
Downloads
Patches
Plain Diff
Added functionality to update tasklabels on events where focus is lost
parent
8e8456f6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
gui/tasksetgui/TaskLabel.java
+30
-2
30 additions, 2 deletions
gui/tasksetgui/TaskLabel.java
with
30 additions
and
2 deletions
gui/tasksetgui/TaskLabel.java
+
30
−
2
View file @
a73b5ad9
...
...
@@ -4,13 +4,16 @@ import java.awt.event.ActionListener;
import
java.awt.event.ActionEvent
;
import
java.awt.event.MouseListener
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.FocusListener
;
import
java.awt.event.FocusEvent
;
import
java.awt.Color
;
import
javax.swing.JTextField
;
import
gui.UpdateListener
;
public
class
TaskLabel
extends
JTextField
implements
MouseListener
{
public
class
TaskLabel
extends
JTextField
implements
FocusListener
,
MouseListener
{
private
String
previousText
;
private
UpdateListener
updateListener
;
private
MarkListener
markListener
;
...
...
@@ -24,6 +27,7 @@ public class TaskLabel extends JTextField implements MouseListener {
// Add Listener for when mouse does something with object
addMouseListener
(
this
);
addFocusListener
(
this
);
// Add Listener that does something with object when <Enter> is pressed
addActionListener
(
new
ActionListener
()
{
...
...
@@ -51,7 +55,10 @@ public class TaskLabel extends JTextField implements MouseListener {
this
.
markListener
=
markListener
;
}
// MouseListener Functions.
/*
* MouseListener Functions.
*/
/*
* Invoked when the mouse button has been clicked (pressed and released) on a component.
*/
...
...
@@ -78,4 +85,25 @@ public class TaskLabel extends JTextField implements MouseListener {
* Invoked when the mouse exits a component.
*/
public
void
mouseExited
(
MouseEvent
e
)
{}
/*
* FocusListener Functions.
*/
/*
* Invoked when a component gains the keyboard focus.
*/
public
void
focusGained
(
FocusEvent
e
)
{
previousText
=
getText
();
}
/*
* Invoked when a component loses the keyboard focus.
*/
public
void
focusLost
(
FocusEvent
e
)
{
if
(!
previousText
.
equals
(
getText
())
&&
getText
().
matches
(
"[0-9]+"
))
{
System
.
out
.
println
(
getText
());
updateListener
.
update
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment