Methods Summary |
---|
public static void | main(java.lang.String[] args)
JFrame frame = new JFrame("Color Chooser Hack");
final JButton button = new JButton("Click to choose a color");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JFrame frame = new ColorChooserDemo(button);
frame.show();
}
});
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
|
public void | mouseClicked(java.awt.event.MouseEvent evt)
|
public void | mouseDragged(java.awt.event.MouseEvent evt)
setSelectedColor(robot.getPixelColor(evt.getX(), evt.getY()));
|
public void | mouseEntered(java.awt.event.MouseEvent evt)
|
public void | mouseExited(java.awt.event.MouseEvent evt)
|
public void | mouseMoved(java.awt.event.MouseEvent evt)
|
public void | mousePressed(java.awt.event.MouseEvent evt)
setSelectedColor(robot.getPixelColor(evt.getX(), evt.getY()));
|
public void | mouseReleased(java.awt.event.MouseEvent evt)
setSelectedColor(robot.getPixelColor(evt.getX(),evt.getY()));
this.setVisible(false);
|
public void | setSelectedColor(java.awt.Color color)
comp.setBackground(color);
label.setBackground(color);
|
public void | show()
try {
// make the screenshot before showing the frame
Rectangle rect = new Rectangle(0,0,
(int)screen_size.getWidth(),
(int)screen_size.getHeight());
this.robot = new Robot();
background_image = robot.createScreenCapture(rect);
super.show();
} catch (AWTException ex) {
System.out.println("exception creating screenshot:");
ex.printStackTrace();
}
|