java实现编辑器的代码 java代码编辑器有哪些( 四 )


{
if(e.getSource()==dialog)
dialog.setVisible(false);//隐藏对话框
else
System.exit(0);
}
public void windowOpened(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public static void main(String args[])
{
Calculator calculator=new Calculator();
}
}
class WinClose implements WindowListener
{
public void windowClosing(WindowEvent e)//单击窗口关闭按钮时触发并执行实现窗口监听器接口中的方法
{
System.exit(0);//结束程序运行
}
public void windowOpened(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
}
求一个用Java编写的文本编辑器代码import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class MyTextEditor extends JFrame implements ActionListener,ItemListener,MouseListener
{
private File file;
private JTextArea textarea;
private JRadioButtonMenuItemrbmi_red,rbmi_blue,rbmi_green;
private JMenuItem menuitem_copy,menuitem_cut,menuitem_paste,menuitem_seek;
private JMenuItem menuitem_song,menuitem_fang,menuitem_kai;//字体变量
private JMenuItem menuitem_normal,menuitem_bold,menuitem_italic;//字形变量
private JMenuItem menuitem_20,menuitem_30,menuitem_40;//字号变量
private JMenuItem menuitem_exit,menuitem_infor;
private JPopupMenu popupmenu;
private JMenuItem menuitem_red,menuitem_green,menuitem_blue;
private JDialog dialog,dialog1;
private JButton button_seek;
private JTextField textfield_seek;
private JLabel label_seek,label_infor;
Stringseek;
public MyTextEditor()
{
super("文本编辑器");
this.setSize(400,300);
this.setLocation(360,300);
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
Container ss=this.getContentPane();
this.textarea = new JTextArea();
JScrollPane dd=new JScrollPane(textarea);
ss.add(dd);
textarea.addMouseListener(this);
this.addMenu();
this.setVisible(true);
this.Dialog();
this.Dialog1();
this.file = null;
}
public MyTextEditor(String filename)
{
this();
if (filename!=null)
{
this.file = new File(filename);
this.setTitle(filename);
this.textarea.setText(this.readFromFile());
}
}
public MyTextEditor(File file)
{
this();
if (file!=null)
{
this.file = file;
this.setTitle(this.file.getName());
this.textarea.setText(this.readFromFile());
}
}
public void Dialog()//建立对话框java实现编辑器的代码的方法
{
dialog=new JDialog(this,"查找",true);
dialog.setLayout(new FlowLayout());
dialog.setSize(200,90);
label_seek=new JLabel("查找内容");
【java实现编辑器的代码 java代码编辑器有哪些】dialog.add(label_seek);
textfield_seek=new JTextField(10);
dialog.add(textfield_seek);
button_seek=new JButton("查找");
dialog.add(button_seek);
button_seek.addActionListener(this);
}
public void Dialog1()
{
dialog1=new JDialog(this,"专利",true);
dialog1.setLayout(new FlowLayout());
dialog1.setSize(200,100);
label_infor=new JLabel("刘同虎制作");
dialog1.add(label_infor);
}
public void addMenu()
{
JMenuBar menubar = new JMenuBar();

推荐阅读