Page 380 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 380
인천전자마이스터고 전자회로설계과
else l=label;
JButton btn = new JButton(l);
btn.addActionListener(this);
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(50,50));
Font font= btn.getFont();
float size=font.getSize();
btn.setFont(font.deriveFont(size));
add(btn);
}
@Override
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
if(actionCommand.equals("X"))
try
{
txt.setText(txt.getText(0,txt.getText().length()-1));
} catch (BadLocationException e1)
{
e1.printStackTrace();
}
else if(actionCommand.equals("ok"))
this.setVisible(false);
e l s e
if(Integer.parseInt(actionCommand)>=0||Integer.parseInt(actionCommand)<=9)
txt.setText(txt.getText()+actionCommand);
}
}
}
- 373 -