0

Consider my simple navigation filter,

class Main
{
JFrame frame=new JFrame();
frame.setSize(400,400);
frame.setLayout(new FlowLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

JTextArea jt=new JTextArea();
jt.setNavigationFilter(new MyNavigationFilter());

frame.add(jt);
}
class MyNavigationFilter extends NavigationFilter
{   
    public void moveDot(FilterBypass fb,int dot, Position.Bias bias)
    {
        System.out.println(bias);
        super.moveDot(fb,dot,bias);
    }

    public void setDot(FilterBypass fb,int dot, Position.Bias bias)
    {
        super.setDot(fb,dot,bias);
    }   
}

When i select the text written in JTextArea using Shift+LEFT_ARROW it is considered to be moving the dot Backward i.e. the PositionBias is Backward.

When I print the bias even when selecting in backward direction, Forward was printed. How does this work?

Any answer will be appreciated. Thanks in advance.

JavaTechnical
  • 8,846
  • 8
  • 61
  • 97

0 Answers0