-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
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 --
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 --