[java swing] 정말정말 궁금해요 !
나샘
자바 스윙 공부를 하고 있습니다.
배경 이미지를 넣고 싶은데 안되네요 ㅠ
아직 왕초보라서요 ㅠ
주석부분을 풀면 이미지가 이상하게 되요 ㅠ
고수님들 알려주세요 ~ import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MemberFrame extends JFrame implements ActionListener {
//Image img;
//public void paint(Graphics g) {
// g.drawImage(img, 3, -130, this);
// }
public MemberFrame() {
//Image img = Toolkit.getDefaultToolkit().getImage(c:\\apple.gif);
Container cp = getContentPane();
cp.setLayout(new GridLayout(7, 1));
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel label = new JLabel(ID:);
JTextField textfield = new JTextField();
textfield.setColumns(10);
JButton button = new JButton(ID 확인);
button.addActionListener(this);
panel.add(label);
panel.add(textfield);
panel.add(button);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(PASSWORD:);
JPasswordField passwordfield = new JPasswordField();
passwordfield.setColumns(10);
panel.add(label);
panel.add(passwordfield);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(PASSWORD 확인:);
passwordfield = new JPasswordField();
passwordfield.setColumns(10);
panel.add(label);
panel.add(passwordfield);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(별명:);
textfield = new JTextField();
textfield.setColumns(10);
panel.add(label);
panel.add(textfield);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(이메일:);
textfield = new JTextField();
textfield.setColumns(10);
panel.add(label);
panel.add(textfield);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(주소:);
textfield = new JTextField();
textfield.setColumns(20);
panel.add(label);
panel.add(textfield);
cp.add(panel);
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
label = new JLabel(전화번호:);
textfield = new JTextField();
textfield.setColumns(10);
panel.add(label);
panel.add(textfield);
panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
button = new JButton(가입);
button.addActionListener(this);
panel.add(button);
cp.add(panel);
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals(ID 확인)) {
JOptionPane.showMessageDialog(null, 사용하지 않는 ID입니다.);
} else if (command.equals(가입)) {
int result = JOptionPane.showConfirmDialog(null, 가입하시겠습니까?, 가입 확인, JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
JOptionPane.showMessageDialog(null, 회원 가입을 축하합니다.);
}
}
}
public static void main(String[] args) {
MemberFrame frame = new MemberFrame();
frnbsp; frame.setTitle(회원 가입);
frame.setSize(300, 300);
frame.show();
}
}