Commit 76cbee39 authored by Nils Vreman's avatar Nils Vreman
Browse files

Improved on the unfocusing when clicking somewhere aside from the label

parent a73b5ad9
......@@ -2,7 +2,7 @@ package gui.tasksetgui;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
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();
}
}
......
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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment