import java.awt.*;
import java.awt.event.*;
public class Natsumi extends WindowAdapter implements
ActionListener,MouseListener
{
Frame f=new Frame();
Button b[]=new Button[3];
MenuBar mb1;
Menu mf1,me1,mh1,md1,mc1,mz1;
CheckboxMenuItem cbmi1=new CheckboxMenuItem();
PopupMenu pm1;
Dialog d;
public void display()
{
String arr[]={"Red","Yellow","Blue"};
int i=0;
f.setSize(320,180);
f.setLocation(400,200);
f.addWindowListener(this);
f.addMouseListener(this);
f.setBackground(Color.lightGray);
f.setTitle("Natsumi Abe");
pm1=new PopupMenu("Natsumi Abe");
pm1.add(new MenuItem("Angel"));
pm1.add(new MenuItem("Nacci"));
pm1.add(new MenuItem("Fiona"));
pm1.addSeparator();
pm1.add(new MenuItem("Exit"));
pm1.addActionListener(this);
f.add(pm1);
d=new Dialog(f,"Natsumi Abe",true);
d.add(new Label("只缘感君一回顾,是我思君暮与朝... ..."),"Center");
d.setSize(250,110);
d.setLocation(500,300);
d.addWindowListener(this);
addmyMenu();
f.setLayout(new FlowLayout(FlowLayout.LEFT));
for(i=0;i<3;i++)
{
b[i]=new Button(arr[i]);
f.add(b[i]);
b[i].addActionListener(this);
}
f.setVisible(true);
}
public void addmyMenu()
{
mb1=new MenuBar();
f.setMenuBar(mb1);
mf1=new Menu("File");
me1=new Menu("Edit");
mh1=new Menu("Help");
mc1=new Menu("Natsumi");
mz1=new Menu("Nacci");
mf1.add(new MenuItem("Angel",new MenuShortcut(KeyEvent.VK_A)));
mf1.add(new MenuItem("Eleven",new MenuShortcut(KeyEvent.VK_E)));
mf1.addSeparator();
md1=new Menu("Maggin");
// mf1.add(md1);
cbmi1=new CheckboxMenuItem("Jason",true);
mf1.add(cbmi1);
mf1.add(new MenuItem("Exit"));
mf1.addActionListener(this);
me1.add(new MenuItem("Natsumi"));
me1.add(new MenuItem("Nacci"));
me1.addActionListener(this);
mb1.add(mf1);
mb1.add(me1);
mb1.add(mh1);
mb1.add(mc1);
mb1.add(mz1);
mb1.add(md1);
}
public void windowClosing(WindowEvent e)
{
if(e.getSource()==d)
d.setVisible(false);
else
System.exit(0);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b[0])
f.setBackground(Color.red);
if(e.getSource()==b[1])
f.setBackground(Color.yellow);
if(e.getSource()==b[2])
f.setBackground(Color.blue);
if(e.getActionCommand()=="Angel")
d.setVisible(true);
if(e.getActionCommand()=="Exit")
System.exit(0);
}
public void mouseClicked(MouseEvent mec)
{
if(mec.getModifiers()==mec.BUTTON3_MASK)
pm1.show(f,mec.getX(),mec.getY());
}
public void mousePressed(MouseEvent mep){}
public void mouseReleased(MouseEvent mer){}
public void mouseEntered(MouseEvent mee){}
public void mouseExited(MouseEvent mex){}
public void mouseDragged(MouseEvent med){}
public static void main(String args[])
{
(new Natsumi()).display();
}
}