I add some images to a JPanel
. Therefore, I add a single image to a JLabel
as an ImageIcon
and add this to the main JPanel
. Although I set the bounds (setBounds) to the image-size, there is a margin of a few pixel on top of the image shown below.
image http://w752749.open.ge.tt/1/files/64dsvTG/0/blob/x675
I also tried to add the images as DisplayJai()
, without success (with DisplayJai
, the images have also been croped in a strange way).
The important part of the code is
JPanel srcJPanel = new JPanel();
srcJPanel.setBounds(posW, posH, width, height);
srcJPanel.setBorder(new LineBorder(Color.GREEN.darker(), 2));
Image image = newImage.getScaledImg().getAsBufferedImage();
JLabel l = new JLabel(new ImageIcon(image));
l.setBorder(new LineBorder(Color.RED.darker(), 2));
srcJPanel.add(l, BorderLayout.CENTER);
MainPanel.add(srcJPanel);
this.validate();
Can anyone help me with this margin?
Thanks a lot.