Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4305049

Component JTextArea does not work with cursor position correctly.


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      Name: kaC94536 Date: 01/17/2000

      Component JTextArea sometimes does not draw cursor position correctly.
      Frame window of following test contains a split pane, witch includes
      JTextArea component and buttons panel.
      By clicking on buttons "Next" and "Prev" you can change fonts of top text area.
      Often you can see that current cursor position does not correspond position of symbol being printed.

      Note that the TextArea component works correctly.


      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;

      public class test extends JFrame {

        static Font[] systemFontArray;
        protected int currentFontCount;
        protected JTextArea textArea;
        static {

        public test() {
          super("JTextArea test");
          currentFontCount = 0;

          textArea = new JTextArea();
          JPanel buttonPanel = new ButtonDemo(this);
          JSplitPane splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, textArea, buttonPanel );
          splitPane.setPreferredSize(new Dimension(500, 300));

          getContentPane().add(splitPane, BorderLayout.CENTER);

        public void nextFont() {
          if (currentFontCount < systemFontArray.length-1) {

        public void prevFont () {
          if (currentFontCount > 0) {

        public void setAreaFont(int i) {
            textArea.setFont(new Font(systemFontArray[i].getFontName(), 0, 12));

        public static void main(String[] args) {
          JFrame frame = new test();
          frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {

      class ButtonDemo extends JPanel implements ActionListener {
          JButton b1, b2;
          test t;

          public ButtonDemo(test areatest) {
              t = areatest;

              b1 = new JButton("next");
              b1.setToolTipText("Get next system font");

              b2 = new JButton("prev");
              b2.setToolTipText("Get previous system font");

          public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand().equals("next")) {
              else {



      Name: kaC94536 Date: 02/02/2000

      When some font is set and some symbols are printed in JTextArea component (for example,
      "m", "l" and many others), the size of cursor displacement does not correspond size of the
      This happens the following fonts are used:

      Bitstream Charter Bitstream Charter Bold Bitstream Charter Bold Italic
      Bitstream Charter Italic monocpaced Courier 10 Pitch
      Courier 10 Pitch Bold Courier 10 Pitch Bold Italic Courier 10 Pitch Italic
      Courier Bold Italic Courier Italic Lucuda Bright Demibold
      Lucuda Bright Demibold Italic Lucuda Bright Italic Lucida Bright Regular
      Lucida Sans Demibold Lucida Sans Demibold Oblique Lucida Sans Oblique
      Lucida Sans Regular Lucida Sans Typewriter Bold Lucida Sans Typewriter Bold Oblique
      Lucida Sans Typewriter Oblique Lucida Sans Typewriter Regular Utopia Bold
      Utopia Bold Italic Utopia Italic Utopia Regular
      dialog dialog.bold dialog.bolditalic
      dialog.italic dialoginput dialoginput.bold
      dialoginput.bolditalic dialoginput.italic monospaced
      monospaced.bold monospaced.bolditalic monospaced.italic
      sansserif sansserif.bold sansserif.bolditalic
      sansserif.italic serif serif.bold





            • Assignee:
              mbronsonsunw Mike Bronson (Inactive)
              kanisimosunw Konstantin Anisimov (Inactive)
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: