Please help me how i can exit from a frame (instead of closing by CTRL+c).
Codes below is being presented in full. its comprise of many lines
================
import java.awt.*;
import java.awt.event.*;
public class Testt
{
public static void main(String[]args) throws NoSuchMethodError
{
Test1 test = new Test1();
}
}
class Test1 implements ActionListener
{
TextField text1, text2, text3;
Label label1,label2;
Button button1, button2,button3,button4,button5,button6;
Frame frame;
MenuBar menubar;
MenuItem item1;
FlowLayout flow;
Menu menu;
public Test1()
{
frame = new Frame("Have a nice day");
frame.setBounds(0,0,500,400);
menubar = new MenuBar();
frame.setMenuBar(menubar);
menu = new Menu("First Menu");
menubar.add(menu);
item1 = new MenuItem("Open");
menu.add(item1);
flow = new FlowLayout();
frame.setLayout(flow);
text1 = new TextField(12);
text2 = new TextField(12);
text3 = new TextField(12);
label1 = new Label(" and ");
label2 = new Label("=");
frame.add(text1);
frame.add(label1);
frame.add(text2);
frame.add(label2);
frame.add(text3);
button1 = new Button(" X ");
button2 = new Button(" / ");
button3 = new Button(" + ");
button4 = new Button(" - ");
button5 = new Button("Clear");
button6 = new Button("Exit");
frame.add(button1);
frame.add(button2);
frame.add(button3);
frame.add(button4);
frame.add(button5);
frame.add(button6);
frame.setVisible(true);
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
}
public void actionPerformed(ActionEvent ee)
{
String msg = new String("Hullo from java");
// Multiply
if(ee.getSource() == button1)
{
Double double1 = new Double(text1.getText());
Double double2 = new Double(text2.getText());
double dd = double1.doubleValue() * double2.doubleValue();
text3.setText(String.valueOf(dd));
}
// Divide
if(ee.getSource() == button2)
{
Double double1 = new Double(text1.getText());
Double double2 = new Double(text2.getText());
double dd = double1.doubleValue() / double2.doubleValue();
text3.setText(String.valueOf(dd));
}
// Add
if(ee.getSource() == button3)
{
Double double1 = new Double(text1.getText());
Double double2 = new Double(text2.getText());
double dd = double1.doubleValue() + double2.doubleValue();
text3.setText(String.valueOf(dd));
}
// Subtract
if(ee.getSource() == button4)
{
Double double1 = new Double(text1.getText());
Double double2 = new Double(text2.getText());
double dd = double1.doubleValue() - double2.doubleValue();
text3.setText(String.valueOf(dd));
}
if(ee.getSource() == button5)
{
text1.setText(null);
text2.setText(null);
text3.setText(null);
}
}
}