Die meistgefragten Interviewfragen und Antworten sowie Online-Tests
Lernplattform fur Interviewvorbereitung, Online-Tests, Tutorials und Live-Ubungen

Baue deine Fahigkeiten mit fokussierten Lernpfaden, Probetests und interviewreifem Inhalt aus.

WithoutBook vereint themenbezogene Interviewfragen, Online-Ubungstests, Tutorials und Vergleichsleitfaden in einem responsiven Lernbereich.

Interview vorbereiten

Without Book Frage stellen

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

Frage. 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.

Veroffentlicht am Sep 28, 2010 Veroffentlicht von Om
Antwort.
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);<
Veroffentlicht am Sep 28, 2010 Veroffentlicht von Arindam Ghosh

Geben Sie Ihre Antwort ein

Vollstandiger Name
E-Mail-Adresse
Antwort
Sicherheitsprufung
Lose dies, um fortzufahren: 2 + 8 = ?
Copyright © 2026, WithoutBook.