有那种可以自定义代码,然后直接插入的文本编辑器软件吗?
答案:2 悬赏:50 手机版
解决时间 2021-02-19 16:31
- 提问者网友:蔚蓝的太阳
- 2021-02-18 19:59
我是做CMS做站的,有时用DW不太方便,我想找一个可以预设标签进入,当仿站时,需要哪个标签,点击一下就插入进去的那种软件,谁有的,会制作也行,不过价格高就算了
最佳答案
- 五星知识达人网友:想偏头吻你
- 2021-02-18 21:20
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 JRadioButtonMenuItem rbmi_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;
String seek;
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() //建立对话框的方法
{
dialog=new JDialog(this,"查找",true);
dialog.setLayout(new FlowLayout());
dialog.setSize(200,90);
label_seek=new JLabel("查找内容");
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();
this.setJMenuBar(menubar);
JMenu menu_file = new JMenu("文件"); //文件菜单
menubar.add(menu_file);
JMenuItem menuitem_open = new JMenuItem("打开");
menu_file.add(menuitem_open);
menuitem_open.addActionListener(this);
JMenuItem menuitem_save = new JMenuItem("保存");
menu_file.add(menuitem_save);
menuitem_save.addActionListener(this);
JMenuItem menuitem_saveas = new JMenuItem("另存为");
menu_file.add(menuitem_saveas);
menuitem_saveas.addActionListener(this);
menuitem_exit=new JMenuItem("退出" );
menu_file.add(menuitem_exit);
menuitem_exit.addActionListener(this);
menuitem_infor=new JMenuItem("信息");
menu_file.add(menuitem_infor);
menuitem_infor.addActionListener(this);
JMenu menu_editor=new JMenu("编辑");//编辑菜单
menubar.add(menu_editor);
menuitem_seek=new JMenuItem("查找");
menu_editor.add(menuitem_seek);
menuitem_seek.addActionListener(this);
menuitem_copy=new JMenuItem("复制");
menuitem_copy.addActionListener(this);
menu_editor.add(menuitem_copy);
menuitem_cut=new JMenuItem("剪切");
menu_editor.add(menuitem_cut);
menuitem_cut.addActionListener(this);
menuitem_paste=new JMenuItem("粘贴");
menu_editor.add(menuitem_paste);
menuitem_paste.addActionListener(this);
JMenuItem menu_color=new JMenu("颜色");//颜色菜单
menu_editor.add(menu_color);
ButtonGroup buttongroup=new ButtonGroup();
rbmi_red=new JRadioButtonMenuItem("红",true);
buttongroup.add(rbmi_red);
menu_color.add(rbmi_red);
rbmi_red.addItemListener(this);
rbmi_blue=new JRadioButtonMenuItem("蓝",true);
buttongroup.add(rbmi_blue);
menu_color.add(rbmi_blue);
rbmi_blue.addItemListener(this);
rbmi_green=new JRadioButtonMenuItem("绿",true);
buttongroup.add(rbmi_green);
menu_color.add(rbmi_green);
rbmi_green.addItemListener(this);
JMenu menu_font=new JMenu("设置字体");//设置字体菜单
menubar.add(menu_font);
menuitem_song=new JMenuItem("宋体");
menu_font.add(menuitem_song);
menuitem_song.addActionListener(this);
menuitem_fang=new JMenuItem("仿宋");
menu_font.add(menuitem_fang);
menuitem_fang.addActionListener(this);
menuitem_kai=new JMenuItem("楷体");
menu_font.add(menuitem_kai);
menuitem_kai.addActionListener(this);
JMenu menu_设置字形");//设置字形菜单
menubar.add(menu_style);
menuitem_bold=new JMenuItem("粗体");
menu_style.add(menuitem_bold);
menuitem_bold.addActionListener(this);
menuitem_italic=new JMenuItem("斜体");
menu_style.add(menuitem_italic);
menuitem_italic.addActionListener(this);
JMenu menu_size=new JMenu("设置字号"); //设置字号菜单
menubar.add(menu_size);
menuitem_20=new JMenuItem("20");
menu_size.add(menuitem_20);
menuitem_20.addActionListener(this);
menuitem_30=new JMenuItem("30");
menu_size.add(menuitem_30);
menuitem_30.addActionListener(this);
menuitem_40=new JMenuItem("40");
menu_size.add(menuitem_40);
menuitem_40.addActionListener(this);
popupmenu=new JPopupMenu(); //快捷菜单
JMenuItem menuitem_red=new JMenuItem("红色");
popupmenu.add(menuitem_red);
menuitem_red.addActionListener(this);
JMenuItem menuitem_green=new JMenuItem("绿色");
popupmenu.add(menuitem_green);
menuitem_green.addActionListener(this);
menuitem_blue=new JMenuItem("蓝色");
popupmenu.add(menuitem_blue);
menuitem_blue.addActionListener(this);
textarea.add(popupmenu); //向文本区内添加快捷菜单
}
public void writeToFile(String lines) //写文件
{
try
{
FileWriter fout = new FileWriter(this.file);
fout.write(lines+"\r\n");
fout.close();
}
catch (IOException ioex)
{
return;
}
}
public String readFromFile() //读文件
{
try
{
FileReader fin = new FileReader(this.file);
BufferedReader bin = new BufferedReader(fin);
String aline="", lines="";
do
{
aline = bin.readLine();
if (aline!=null)
lines += aline + "\r\n";
} while (aline!=null);
bin.close();
fin.close();
return lines;
}
catch (IOException ioex)
{
return null;
}
}
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 JRadioButtonMenuItem rbmi_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;
String seek;
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() //建立对话框的方法
{
dialog=new JDialog(this,"查找",true);
dialog.setLayout(new FlowLayout());
dialog.setSize(200,90);
label_seek=new JLabel("查找内容");
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();
this.setJMenuBar(menubar);
JMenu menu_file = new JMenu("文件"); //文件菜单
menubar.add(menu_file);
JMenuItem menuitem_open = new JMenuItem("打开");
menu_file.add(menuitem_open);
menuitem_open.addActionListener(this);
JMenuItem menuitem_save = new JMenuItem("保存");
menu_file.add(menuitem_save);
menuitem_save.addActionListener(this);
JMenuItem menuitem_saveas = new JMenuItem("另存为");
menu_file.add(menuitem_saveas);
menuitem_saveas.addActionListener(this);
menuitem_exit=new JMenuItem("退出" );
menu_file.add(menuitem_exit);
menuitem_exit.addActionListener(this);
menuitem_infor=new JMenuItem("信息");
menu_file.add(menuitem_infor);
menuitem_infor.addActionListener(this);
JMenu menu_editor=new JMenu("编辑");//编辑菜单
menubar.add(menu_editor);
menuitem_seek=new JMenuItem("查找");
menu_editor.add(menuitem_seek);
menuitem_seek.addActionListener(this);
menuitem_copy=new JMenuItem("复制");
menuitem_copy.addActionListener(this);
menu_editor.add(menuitem_copy);
menuitem_cut=new JMenuItem("剪切");
menu_editor.add(menuitem_cut);
menuitem_cut.addActionListener(this);
menuitem_paste=new JMenuItem("粘贴");
menu_editor.add(menuitem_paste);
menuitem_paste.addActionListener(this);
JMenuItem menu_color=new JMenu("颜色");//颜色菜单
menu_editor.add(menu_color);
ButtonGroup buttongroup=new ButtonGroup();
rbmi_red=new JRadioButtonMenuItem("红",true);
buttongroup.add(rbmi_red);
menu_color.add(rbmi_red);
rbmi_red.addItemListener(this);
rbmi_blue=new JRadioButtonMenuItem("蓝",true);
buttongroup.add(rbmi_blue);
menu_color.add(rbmi_blue);
rbmi_blue.addItemListener(this);
rbmi_green=new JRadioButtonMenuItem("绿",true);
buttongroup.add(rbmi_green);
menu_color.add(rbmi_green);
rbmi_green.addItemListener(this);
JMenu menu_font=new JMenu("设置字体");//设置字体菜单
menubar.add(menu_font);
menuitem_song=new JMenuItem("宋体");
menu_font.add(menuitem_song);
menuitem_song.addActionListener(this);
menuitem_fang=new JMenuItem("仿宋");
menu_font.add(menuitem_fang);
menuitem_fang.addActionListener(this);
menuitem_kai=new JMenuItem("楷体");
menu_font.add(menuitem_kai);
menuitem_kai.addActionListener(this);
JMenu menu_设置字形");//设置字形菜单
menubar.add(menu_style);
menuitem_bold=new JMenuItem("粗体");
menu_style.add(menuitem_bold);
menuitem_bold.addActionListener(this);
menuitem_italic=new JMenuItem("斜体");
menu_style.add(menuitem_italic);
menuitem_italic.addActionListener(this);
JMenu menu_size=new JMenu("设置字号"); //设置字号菜单
menubar.add(menu_size);
menuitem_20=new JMenuItem("20");
menu_size.add(menuitem_20);
menuitem_20.addActionListener(this);
menuitem_30=new JMenuItem("30");
menu_size.add(menuitem_30);
menuitem_30.addActionListener(this);
menuitem_40=new JMenuItem("40");
menu_size.add(menuitem_40);
menuitem_40.addActionListener(this);
popupmenu=new JPopupMenu(); //快捷菜单
JMenuItem menuitem_red=new JMenuItem("红色");
popupmenu.add(menuitem_red);
menuitem_red.addActionListener(this);
JMenuItem menuitem_green=new JMenuItem("绿色");
popupmenu.add(menuitem_green);
menuitem_green.addActionListener(this);
menuitem_blue=new JMenuItem("蓝色");
popupmenu.add(menuitem_blue);
menuitem_blue.addActionListener(this);
textarea.add(popupmenu); //向文本区内添加快捷菜单
}
public void writeToFile(String lines) //写文件
{
try
{
FileWriter fout = new FileWriter(this.file);
fout.write(lines+"\r\n");
fout.close();
}
catch (IOException ioex)
{
return;
}
}
public String readFromFile() //读文件
{
try
{
FileReader fin = new FileReader(this.file);
BufferedReader bin = new BufferedReader(fin);
String aline="", lines="";
do
{
aline = bin.readLine();
if (aline!=null)
lines += aline + "\r\n";
} while (aline!=null);
bin.close();
fin.close();
return lines;
}
catch (IOException ioex)
{
return null;
}
}
全部回答
- 1楼网友:从此江山别
- 2021-02-18 22:44
不好意思 做任务呢 打搅了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯