hipal
asked on
adding JButton to painted image in JPanel
Hi Guys,
Thanks for all the help.
I am painting images on JPanel. (Like code snippet attached .. not complete though)
I am trying to add a JButton to each image such that when I am moving the image .. JButton should move with it ..
My class is currently extending JComponent. and images i am adding are instance of that class.
Code excerpt attached are from Photos class only which extends JComponent.
Thanks for all the help.
I am painting images on JPanel. (Like code snippet attached .. not complete though)
I am trying to add a JButton to each image such that when I am moving the image .. JButton should move with it ..
My class is currently extending JComponent. and images i am adding are instance of that class.
Code excerpt attached are from Photos class only which extends JComponent.
@Override
public void paint(Graphics g){
int w = getWidth();
int h = getHeight();
Graphics2D g2 = (Graphics2D) g;
g2.addRenderingHints(new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON));
AffineTransform transform = g2.getTransform();
transform.concatenate(_transform);
g2.setTransform(transform);
g2.setClip(0, 0, w, h);
g2.drawImage(_image, 0, 0, w, h, 0, 0, _image.getWidth(this), _image.getHeight(this), this);
super.paintComponent(g);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window