4
배경을 설정하는 방법 JOptionPane의 이미지? JOptionPane의 배경에 다른 이미지를 표시하고 싶습니다.JOptionPane 배경 이미지
배경을 설정하는 방법 JOptionPane의 이미지? JOptionPane의 배경에 다른 이미지를 표시하고 싶습니다.JOptionPane 배경 이미지
JOptionPane 클래스를 확장하고 paint 메소드를 재정의 할 수 있습니다.
편집 : 이미지 해상도 및 품질에 따라 WindowResize 이벤트 중에 AffineTransform으로 이미지 왜곡없이 확대 할 수 있습니다. 이것에 의해, JOptionPane 및 이미지 사이즈 불일치를 처리 할 수 있습니다.
class ImageBackgroundPane extends JOptionPane
{
private BufferedImage img;
public ImageBackgroundPane (BufferedImage image)
{
this.img = image;
}
@Override
public void paint(Graphics g)
{
//Pick one of the two painting methods below.
//Option 1:
//Define the bounding region to paint based on image size.
//Be careful, if the image is smaller than the JOptionPane size you
//will see a solid white background where the image does not reach.
g.drawImage(img, 0, 0, img.getWidth(), img.getHeight());
//Option 2:
//If the image can be guaranteed to be larger than the JOptionPane's size
Dimension curSize = this.getSize();
g.drawImage(img, 0, 0, curSize.width, curSize.height, null);
//Make sure to paint all the other properties of Swing components.
super.paint(g);
}
}
작동하지 않습니다 ... 실례를 들어 주시겠습니까? –
해결책을 찾고 있는데, 뭔가 찾았습니까? – trinity420