가장 많이 묻는 면접 질문과 답변 & 온라인 테스트
면접 준비, 온라인 테스트, 튜토리얼, 라이브 연습을 위한 학습 플랫폼

집중 학습 경로, 모의고사, 면접 준비 콘텐츠로 실력을 키우세요.

WithoutBook은 주제별 면접 질문, 온라인 연습 테스트, 튜토리얼, 비교 가이드를 하나의 반응형 학습 공간으로 제공합니다.

Prepare Interview

Without Book 질문하기

Review the question and existing answers carefully before replying. The best answers explain the reasoning, steps, and tradeoffs so other learners can benefit too.

질문. Please give me a source code example that makes a calculator on java. awt or swing anything can be given.

- Please give me a source code example that makes a calculator on java. awt or swing anything can be given.

작성일 Sep 28, 2010 작성자 Om
답변.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class CalculatorPanel extends JPanel
implements ActionListener
{ public CalculatorPanel()
{ setLayout(new BorderLayout());

display = new JTextField("0");
display.setEditable(false);
add(display, "North");

JPanel p = new JPanel();
p.setLayout(new GridLayout(4, 4));
String buttons = "789/456*123-0.=+";
for (int i = 0; i < buttons.length(); i++)
addButton(p, buttons.substring(i, i + 1));
add(p, "Center");
}

private void addButton(Container c, String s)
{ JButton b = new JButton(s);
c.add(b);
b.addActionListener(this);
}

public void actionPerformed(ActionEvent evt)
{ String s = evt.getActionCommand();
if ('0' <= s.charAt(0) && s.charAt(0) <= '9'
'' s.equals("."))
{ if (start) display.setText(s);<
작성일 Sep 28, 2010 작성자 Arindam Ghosh

답변 입력

이름
이메일 주소
답변
보안 확인
계속하려면 풀어주세요: 7 + 2 = ?
Copyright © 2026, WithoutBook.