-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLimitFilter.java
More file actions
32 lines (30 loc) · 832 Bytes
/
Copy pathLimitFilter.java
File metadata and controls
32 lines (30 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import javax.swing.*;
import javax.swing.text.NavigationFilter;
import javax.swing.text.Position;
public class LimitFilter extends NavigationFilter {
private int maxSize;
private JTextField cell;
LimitFilter(int maxSize, JTextField cell){
super();
this.maxSize = maxSize;
this.cell = cell;
}
@Override
public void setDot(FilterBypass fb, int dot, Position.Bias bias) {
if (dot >= maxSize) {
fb.setDot(0, bias);
cell.transferFocus();
return;
}
fb.setDot(dot, bias);
}
@Override
public void moveDot(FilterBypass fb, int dot, Position.Bias bias) {
if (dot >= maxSize) {
fb.setDot(0, bias);
cell.transferFocus();
return;
}
fb.moveDot(dot, bias);
}
}