NavigationFilter.FilterBypass.setDot(int dot, Bias bias) : NavigationFilter « javax.swing.text « Java by API






NavigationFilter.FilterBypass.setDot(int dot, Bias bias)

 


import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.text.NavigationFilter;
import javax.swing.text.Position;

public class Main {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Navigation Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    frame.add(scrollPane, BorderLayout.CENTER);

    NavigationFilter filter = new NavigationFilter() {
      public void setDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) {
        System.out.println("Setting: " + dot);
        fb.setDot(dot, bias);

      }

      public void moveDot(NavigationFilter.FilterBypass fb, int dot, Position.Bias bias) {
        System.out.println("Moving: " + dot);
        fb.setDot(dot, bias);
      }
    };

    textArea.setNavigationFilter(filter);

    frame.setSize(250, 150);
    frame.setVisible(true);
  }
}

   
  








Related examples in the same category

1.implements NavigationFilter