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
76cbee39
Commit
76cbee39
authored
6 years ago
by
Nils Vreman
Browse files
Options
Downloads
Patches
Plain Diff
Improved on the unfocusing when clicking somewhere aside from the label
parent
a73b5ad9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
gui/tasksetgui/TaskLabel.java
+10
-36
10 additions, 36 deletions
gui/tasksetgui/TaskLabel.java
gui/tasksetgui/TasksetDisplay.java
+8
-0
8 additions, 0 deletions
gui/tasksetgui/TasksetDisplay.java
with
18 additions
and
36 deletions
gui/tasksetgui/TaskLabel.java
+
10
−
36
View file @
76cbee39
...
...
@@ -2,7 +2,7 @@ package gui.tasksetgui;
import
java.awt.event.ActionListener
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.Mouse
Listen
er
;
import
java.awt.event.Mouse
Adapt
er
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.FocusListener
;
import
java.awt.event.FocusEvent
;
...
...
@@ -11,7 +11,7 @@ import javax.swing.JTextField;
import
gui.UpdateListener
;
public
class
TaskLabel
extends
JTextField
implements
FocusListener
,
MouseListener
{
public
class
TaskLabel
extends
JTextField
implements
FocusListener
{
private
String
previousText
;
private
UpdateListener
updateListener
;
...
...
@@ -25,8 +25,7 @@ public class TaskLabel extends JTextField implements FocusListener, MouseListene
setDocument
(
new
TaskLabelFilter
());
setText
(
text
);
// Add Listener for when mouse does something with object
addMouseListener
(
this
);
// Add Listener for when focus is placed inside
addFocusListener
(
this
);
// Add Listener that does something with object when <Enter> is pressed
...
...
@@ -37,6 +36,13 @@ public class TaskLabel extends JTextField implements FocusListener, MouseListene
}
}
});
// Add Listener that does something When object is clicked
addMouseListener
(
new
MouseAdapter
()
{
public
void
mouseClicked
(
MouseEvent
e
)
{
markListener
.
markUpdate
(
this
);
}
});
}
/*
...
...
@@ -55,37 +61,6 @@ public class TaskLabel extends JTextField implements FocusListener, MouseListene
this
.
markListener
=
markListener
;
}
/*
* MouseListener Functions.
*/
/*
* Invoked when the mouse button has been clicked (pressed and released) on a component.
*/
public
void
mouseClicked
(
MouseEvent
e
)
{
markListener
.
markUpdate
(
this
);
}
/*
* Invoked when a mouse button has been pressed on a component.
*/
public
void
mousePressed
(
MouseEvent
e
)
{}
/*
* Invoked when a mouse button has been released on a component.
*/
public
void
mouseReleased
(
MouseEvent
e
)
{}
/*
* Invoked when the mouse enters a component.
*/
public
void
mouseEntered
(
MouseEvent
e
)
{}
/*
* Invoked when the mouse exits a component.
*/
public
void
mouseExited
(
MouseEvent
e
)
{}
/*
* FocusListener Functions.
*/
...
...
@@ -102,7 +77,6 @@ public class TaskLabel extends JTextField implements FocusListener, MouseListene
*/
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.
gui/tasksetgui/TasksetDisplay.java
+
8
−
0
View file @
76cbee39
package
gui.tasksetgui
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
javax.swing.BoxLayout
;
import
javax.swing.JPanel
;
import
java.awt.Dimension
;
...
...
@@ -30,6 +32,12 @@ public class TasksetDisplay extends BoxPanel implements Observer, UpdateListener
this
.
taskset
=
taskset
;
taskset
.
addObserver
(
this
);
addMouseListener
(
new
MouseAdapter
()
{
public
void
mouseClicked
(
MouseEvent
e
)
{
grabFocus
();
}
});
add
(
header
);
setMaximumSize
(
new
Dimension
(
300
,
35
));
add
(
createVerticalStrut
(
offset
));
...
...
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