일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 안드로이드 개발 강좌
- 하루 한마디 영어
- 안드로이드 2.0 개발
- 스카이 안드로이드폰 시리우스
- 안드로이드 개발 2.0 강좌
- 스마트폰 배경화면
- 안드로이드 배경화면
- Form Stuff
- 영어
- 안드로이드
- 안드로이드개발
- 구글 안드로이드 개발
- objective-c
- 스카이 안드로이드폰 시리우스 K양 동영상
- 안드로이드2.0개발
- 구글안드로이드
- 하루한마디영어
- 아이폰 바탕화면
- SKY 시리우스
- 안드로이드폰
- 안드로이드 바탕화면
- 인기있는 블로그 만들기
- android
- MapView
- 아이폰 배경화면
- 안드로이드 개발
- 안드로이드2.0
- 구글 안드로이드
- sky 시리우스폰
- 안드로이드 개발 2.0
- Today
- Total
moozi
Gallery02 본문
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public class Gallery02 extends JFrame{
private String[] fruits= {"사과","배","체리"};
private JComboBox<String> strCombo=new JComboBox<String>(fruits);
private JLabel imageLabel=new JLabel();
private ImageIcon[] image= {
new ImageIcon("images/apple.png"),
new ImageIcon("images/pear.png"),
new ImageIcon("images/cherry.png")
};
public Gallery02() {
this.setTitle("갤러리");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=this.getContentPane();
//라디오버튼이 올라갈 패널
JPanel radioPanel=new JPanel();
radioPanel.setBackground(Color.GRAY);
//콤포박스 이벤트처리
this.strCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JComboBox<String> cb=(JComboBox<String>)e.getSource();
int index=cb.getSelectedIndex();
imageLabel.setIcon(image[index]);
}});
//라디오패널에 콤포박스추가
radioPanel.add(strCombo);
//첫번째 이미지 선택.기본값.
this.imageLabel.setIcon(image[0]);
this.imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
c.add(radioPanel, BorderLayout.NORTH);
c.add(imageLabel, BorderLayout.CENTER);
this.setSize(500, 500);
this.setVisible(true);
}
public static void main(String[] args) {
new Gallery02();
}
}