2008년 6월 22일 일요일

Exeption in thread "main" java.lang.NullPointerException


import java.awt.*;

import java.awt.event.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;

import javax.swing.*;

class UpdateInfo extends JFrame
{
private JPanel pmain, pupper, pcenter, pbottom;
private JLabel lname, lemail, lplace;
private JTextField tfname, tfemail, tfplace;
private JButton bInput, bReset, bClose;

public UpdateInfo()
{
setTitle("Update Infomation");
Container c = getContentPane();
pmain = new JPanel();
pupper = new JPanel();// 추가하세요.
lname = new JLabel("성 명");
tfname = new JTextField(5);
lemail = new JLabel("이메일");
tfemail = new JTextField(15);
pcenter = new JPanel();
lplace = new JLabel("주 소");
tfplace = new JTextField(25);
pbottom = new JPanel();
bInput = new JButton("입 력");
bReset = new JButton("새로고침");
bClose = new JButton("닫 기");
bClose.setToolTipText("종료하기");
bClose.setCursor(new Cursor(Cursor.HAND_CURSOR));
bClose.addMouseListener(new TryClose());

pupper.add(lname);
pupper.add(tfname);
pupper.add(lemail);
pupper.add(tfemail);
pcenter.add(lplace);
pcenter.add(tfplace);
pbottom.add(bInput);
pbottom.add(bReset);
pbottom.add(bClose);
pmain.add("North", pupper);
pmain.add("Center", pcenter);
pmain.add("South", pbottom);
add(pmain);

bReset.addActionListener(new ButtonHandler());
bInput.addActionListener(new ButtonHandler());
setResizable(false);
setSize(400,150);
setVisible(true);
setDefaultLookAndFeelDecorated(true);
}

public class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String string = "";
if(e.getSource() == bReset)
{
tfname.setText("");
tfemail.setText("");
tfplace.setText("");
}
else if(e.getSource() == bInput)
{
string = String.format("성명 : "+ tfname.getText() + "E-mail : " + tfemail.getText() + "\n주소 : " + tfplace.getText(),e.getActionCommand());

JOptionPane.showMessageDialog(null, string);
}
}
}

public class TryClose extends MouseAdapter
{
public void mousePressed(MouseEvent ev)
{
dispose();
// new TestLogin(); // 지금은 필요 없음
}
}

public static void main(String[] args)
{
UpdateInfo ui = new UpdateInfo();
}
}

댓글 없음:

댓글 쓰기

-


Sidewinder


World


FishMusic


LaughingBaby