이미지를 보여주는 패널에 JScrollPane의 추가하지만 난 .. 그것을 스크롤을 추가 할 수 아니에요이 내 코드내가 apanel ..에 이미지를 표시하기위한이 작은 프로그램이
클래스입니다
public class ShowPanel extends JPanel{
public ShowPanel(BufferedImage image, int height, int width) {
this.image = image;
this.height = height;
this.width = width;
//this.setBounds(width, width, width, height);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, height, width, null);
}
public void setImage(BufferedImage image, int height, int width) {
this.image = image;
this.height = height;
this.width = width;
}
private BufferedImage image;
private int height;
private int width;
}
하고 보여주는 패널 개최 imageContainer라는 또 다른 패널이 메인 프레임의 샘플 :
public class MainFrame extends javax.swing.JFrame {
/** Creates new form MainFrame */
public MainFrame() {
initComponents();
image = null;
path = "PantherOnLadder.gif";
image = Actions.loadImage(path);
showPanel = new ShowPanel(image, 0, 0);
spY = toolBar.getY() + toolBar.getHeight();
showPanel.setBounds(0, spY, image.getWidth(), image.getHeight());
showPanel.repaint();
imageContainer.add(showPanel);
JScrollPane scroller = new JScrollPane(imageContainer);
scroller.setAutoscrolls(true);
}
를 이미지를 보여 JPanel의 확장
내가 여기서 한 실수는 무엇입니까?
감사합니다 .. 잘 이미지도 – CiCi
에 scalnig 및 ather 것들을 할 것이지만 스케일링조차도 JLabel의 "paint"메소드를 오버라이드하여 처리 할 수 있습니다 – aperkins