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

Kestrel-FCS-O:Robot screen capture does not capture properly for 256 colors.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta
    • x86
    • windows_nt
    • Verified

      Kestrel-FCS-O:Robot screen capture does not capture properly for 256 colors. To see the problem, set the colors on a Windows NT machine to 256 and run the sample code below. Click on the Capture button to see the captured image in another frame.

      It works fine on Solaris and on settings using more number of colors.

      -- Sample Code --
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class ScrnCapture extends JFrame {
      Robot rbt = null;
      JButton jbn = null;

      public ScrnCapture() {
      setDefaultCloseOperation(3);
      try {
      rbt = new Robot();
      }
      catch(Exception e) {
      System.err.println(e);
      }
      getContentPane().setLayout(new BorderLayout());
      getContentPane().add("Center", new JLabel(new ImageIcon("bn.gif")));

      jbn = new JButton("Capture");
      jbn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      doCapture();
      }
      });
      getContentPane().add("South", jbn);

      pack();
      show();
      }

      public void doCapture() {
      Rectangle rect = getBounds();
      Image img = rbt.createScreenCapture(rect);

      JFrame fr = new JFrame();
      fr.setDefaultCloseOperation(3);
      fr.getContentPane().add(new JLabel(new ImageIcon(img)));

      fr.pack();
      fr.show();
      }

      public static void main(String argv[]) {
      new ScrnCapture();
      }
      }
      -- Sample Code --

            dmikhalksunw Denis Mikhalkin (Inactive)
            mmadhugisunw Mukund Madhugiri (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: