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

setCursor() doesn't work for Component or JComponent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • generic, x86
    • generic, windows_nt



      Name: krT82822 Date: 11/20/98


      The cursor doesn't change when I run this program, whether the parent class is Component or JComponent. However if I extend from JButton, it does work.




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

      class SetCursor extends Component {
          SetCursor() {
      //
              setCursor(Cursor.getPredefinedCursor(Cursor./*i*/HAND_CURSOR/**/));
      //
          }
          public void paint(Graphics g) {
              Graphics2D g2d = (Graphics2D)g;

              g2d.drawOval(0, 0, getSize().width-1, getSize().height-1);
          }

          public static void main(String[] args) {
              JFrame frame = new JFrame();
              frame.getContentPane().add(new SetCursor());
              frame.setSize(300, 300);
              frame.setVisible(true);
          }
      }
      (Review ID: 42777)
      ======================================================================

            xdengsunw Xianfa Deng (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: