>>92
public class MyComponent extends JComponent implements MouseListener {
public static void main(String[] args) throws IOException {
JFrame frame = new JFrame("test");
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(new MyComponent(), BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
private BufferedImage img;
public MyComponent() throws IOException {
img = ImageIO.read(getClass().getResource("unagi.bmp"));
setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));
addMouseListener(this);
}
public void paint(Graphics g) {
g.drawImage(img, 0, 0, this);
}
public void mousePressed(MouseEvent ev) {
int argb = img.getRGB(ev.getX(), ev.getY());
System.out.println(Integer.toHexString(argb));
}
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
}

うなぎ画像でテスト済み