2
이것은 클래스 프로젝트이며 하나 이상의 이미지를 표시해야하지만 마지막 label.setIcon 만 인쇄합니다. 어떻게해야합니까? JLabel
는 하나의 Image
를 저장할 수 있기 때문에 발생JLabel에 여러 이미지를 표시하는 방법
package Rectangle;
import java.awt.*;
import javax.swing.*;
public class Rectangle extends JFrame {
public Rectangle(String arg) {
JPanel panel = new JPanel();
panel.setBackground(Color.BLACK);
ImageIcon icon = new ImageIcon(this.getClass().getResource("1676858-livingforest2011.jpg"));
ImageIcon icon1 = new ImageIcon(this.getClass().getResource("20496aa0.gif"));
ImageIcon icon2 = new ImageIcon(this.getClass().getResource("akuma-ragingdemon-yes.gif"));
JLabel label = new JLabel();
label.setIcon(icon2);
label.setIcon(icon1);
label.setIcon(icon);
panel.add(label);
this.getContentPane().add(panel);
}
public static void main(String[] args) {
Rectangle forestFrame = new Rectangle(args.length == 0 ? null : args[3]);
forestFrame.setSize(1698,770);
forestFrame.setVisible(true);
forestFrame.setVisible(true);
}
}
또한 아이콘 2와 3의 위치를 변경하는 방법을 궁금합니다. – EddJack
['LyoutManager'] (http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html)의 도움으로이를 관리 할 수 있습니다. 예를 들어'BorderLayout'을 시도해보십시오. – alex2410