Thread: Calculator code
View Single Post
Old 05-14-2008, 12:58 PM   #4 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 59
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
Thumbs up

use JFrame and JPanel instead of just normal Frame and Panel by using
Code:
import javax.swing.*;
and get rid of container, in the end your main function should look like this.
Code:
public static void main(String[] args) {
     JFrame frame = new JFrame();
    frame.setTitle("Calculator");
    frame.setSize(200, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new Calculator());
    frame.setVisible(true);
}
JFrame has the .setDefaultCloseOperation() method so that takes the place of your listener and 5 lines of code.

with all those changes it works fine for me and looks great. GJ.
Rotkiv is offline   Reply With Quote