写了一个 你看看是你要的不
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class bjq extends JFrame
{
JTextArea ta1;
Font font0=new Font("",Font.BOLD,12);
Font font1=new Font("",Font.ITALIC,12);
Font font2=new Font("",Font.PLAIN,12);
Font font3=new Font("宋体",Font.PLAIN,12);
Font font4=new Font("楷体_GB2312",Font.PLAIN,12);
bjq()
{
ta1=new JTextArea();
JMenuBar mb1=new JMenuBar();
JMenu fi=new JMenu("File");
JMenu e=new JMenu("Edit");
JMenu o=new JMenu("Option");
JMenuItem file1=new JMenuItem("Exit");
JMenuItem edit[]=
{
new JMenuItem("Copy"),
new JMenuItem("Cut"),
new JMenuItem("Paste"),
new JMenuItem("DeleteAll")
};
JMenuItem zt[]=
{
new JMenuItem("加粗"),
new JMenuItem("斜体"),
new JMenuItem("普通"),
new JMenuItem("宋体"),
new JMenuItem("楷体_GB2312"),
};
JScrollPane sp1= new JScrollPane(ta1);
add(sp1);
mb1.add(fi);
fi.add(file1);
mb1.add(e);
for(int i=0;i<4;i++)
{
e.add(edit[i]);
}
for(int i=0;i<5;i++)
{
o.add(zt[i]) ;
}
mb1.add(o);
setJMenuBar(mb1);
setVisible(true);
setSize(600,400);
setTitle("编辑器");
file1.addActionListener(new file1l());
edit[0].addActionListener(new edit0l());
edit[1].addActionListener(new edit1l());
edit[2].addActionListener(new edit2l());
edit[3].addActionListener(new edit3l());
zt[0].addActionListener(new zt0l());
zt[1].addActionListener(new zt1l());
zt[2].addActionListener(new zt2l());
zt[3].addActionListener(new zt3l());
zt[4].addActionListener(new zt4l());
}
class file1l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
class edit0l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.copy();
}
}
class edit1l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.cut();
}
}
class edit2l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.paste();
}
}
class edit3l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setText("");
}
}
class zt0l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setFont(font0);
}
}
class zt1l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setFont(font1);
}
}
class zt2l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setFont(font2);
}
}
class zt3l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setFont(font3);
}
}
class zt4l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
ta1.setFont(font4);
}
}
protected void processWindowEvent(WindowEvent e)
{
if(e.getID()==WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}
}
public static void main(String arg[])
{
new bjq();
}
}