javafeditor的简单介绍

博主:adminadmin 2022-11-29 18:41:10 52

本篇文章给大家谈谈javafeditor,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java.lang.NumberFormatException: For input string: "lbbrowse"

很简单的问题,你试图将字符串“Ibbrowse”转为Double类型,结果出错了;

建议:对输入的字符串进行格式控制,比如正则表达式判断是否为数字;

我用java读取RTF文档,读出来的汉字都是乱码 那位大侠给个解决办法

没理由啊!你确定运行的时候去掉了“ //String re = new String(m_doc.getText(0,m_doc.getLength()).getBytes("ISO8859_1"));”的“//”了??

严重: Servlet.service() for servlet jsp threw exception 求解

你看看你这个类FCKeditor.java的263。String字符串在截取(substring)的时候越界了。仔细查查,String的长度和substring里面的参数长度。

java文本编辑器FileEditor

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

public class f1 extends Frame implements ActionListener

{

private MenuBar menubar=new MenuBar();

private Menu filemenu=new Menu("文件");

private Menu editmenu=new Menu("编辑");

private Menu formmenu=new Menu("格式");

private MenuItem[] itemf=new MenuItem[4];

private MenuItem[] iteme=new MenuItem[6];

private MenuItem[] items=new MenuItem[2];

private TextArea tf=new TextArea();

public int a=0,b=0,c=0,style=Font.PLAIN,size=15;

public String s1="red:"+a+" "+"green:"+b+" "+"blue"+c,

s2="宋体";

public

用JAVA编个简单的记事本程序

import java.awt.event.*;

import java.awt.*;

import java.io.*;

import java.util.Calendar;

import java.util.Date;

import javax.swing.*;

class Editor extends Frame implements ActionListener,ItemListener

{

// Date date=new Date();

int n1;String str="";int k=0;String st1,st2;

JTextArea ta=new JTextArea(50,50);

Dialog dialog,dialog1;

Choice ce1,ce2,ce3;

Button btn1,btn2,btn3;Panel p1=new Panel();

Panel p2=new Panel();Panel p3=new Panel();Panel p4=new Panel();

public Editor (String s)

{

super ("记事本编辑板");

ImageIcon YouImg = new ImageIcon("iconimage.jpg");

setIconImage(YouImg.getImage());

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

dispose();

System.exit(0);

}

});

setBounds(50,35,700,500);

MenuBar mb=new MenuBar();

setMenuBar(mb);

Menu file=new Menu("文件(F)");Menu edit=new Menu("编辑(E)");Menu help=new Menu("帮助(H)");

Menu pattern=new Menu("格式(P)");Menu time=new Menu("时间(T)");

MenuItem exit=new MenuItem("退出",new MenuShortcut(KeyEvent.VK_Q));

MenuItem tdate=new MenuItem("日期/时间",new MenuShortcut(KeyEvent.VK_D));

MenuItem renew=new MenuItem("新建", new MenuShortcut(KeyEvent.VK_N));

MenuItem save=new MenuItem("保存", new MenuShortcut(KeyEvent.VK_S));

MenuItem open=new MenuItem("打开",new MenuShortcut(KeyEvent.VK_O));

MenuItem copy=new MenuItem("复制",new MenuShortcut(KeyEvent.VK_C));

MenuItem paste=new MenuItem("粘贴",new MenuShortcut(KeyEvent.VK_V));

MenuItem cut=new MenuItem("剪切",new MenuShortcut(KeyEvent.VK_X));

MenuItem helptopic=new MenuItem("主题",new MenuShortcut(KeyEvent.VK_T));

helptopic.addActionListener(this);

dialog=new Dialog(this, "字体设置");dialog.setSize(300,300);

dialog1=new Dialog(this, "帮助主题");dialog1.setBounds(250,100,300,400);

dialog.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

dialog.setVisible(false);}

});

dialog1.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

dialog1.setVisible(false);}

});

//dialog.setBackground(Color.WHITE);

dialog.setLayout(null);dialog.setBounds(170,150,450,300);

Label L1=new Label("字体(F)");Label L2=new Label("字形(Y)");

Label L3=new Label("大小(S)");TextArea ta1=new TextArea(5,5);

ta1=new TextArea("至于记事本的主题嘛,因为本人的水平有限, 所有不能为大家作过多的指导,望大家见谅!"); //在这里我想加一个文本框用来放帮助信息。

ce1=new Choice();ce2=new Choice();

ce3=new Choice();

btn1=new Button("确定");btn2=new Button("取消");btn1.addActionListener(this);btn2.addActionListener(this);

btn3=new Button("颜色");

btn3.addActionListener(this);

ce1.add("华文行楷");ce1.add("华文中宋");ce1.add("华文新魏");ce1.add("华文细黑");ce1.add("宋体");ce1.add("方正姚体");

ce1.add("幼圆");ce1.add("隶书");ce1.add("楷体-GB2312");ce1.add("华文行楷");ce1.add("华文彩云");ce1.add("仿宋-GB2312");

ce2.add("粗体");ce2.add("斜体");ce2.add("常规");

for(int n1=0;n1=100;n1++)

{ce3.add(""+n1);}

dialog.add(p1);p1.setBounds(5,30,440,35);p1.setLayout( null);//p1.setBackground(Color.red);

dialog.add(p2);p2.setBounds(5,65,440,27);dialog.add(p3);p3.setBounds(5,90,440,40);//p4.setBounds(5,120,440,138);

p1.setLayout( null);

p1.add(L1);L1.setBounds(5,15,50,25);p1.add(L2);L2.setBounds(150,15,50,25);

p1.add(L3);L3.setBounds(250,15,50,25);p2.setLayout( null);//p2.setBackground(Color.yellow);

p2.add(ce1);ce1.setBounds(5,0,130,25);p2.add(ce2);ce2.setBounds(160,0,90,25);p2.add(ce3);ce3.setBounds(260,0,75,25);

p2.add(btn1);btn1.setBounds(360,0,75,25);

p3.setLayout( null);p3.add(btn2);btn2.setBounds(360,10,75,25);p3.add(btn3);btn3.setBounds(160,10,75,25);

dialog.add(p4);p4.setBackground(Color.yellow);p4.setBounds(5,120,440,138);

dialog1.add(ta1);

//设置字体的下拉情况

MenuItem Font=new MenuItem("字体");//给字体加监听器

Font.addActionListener(this);

MenuItem Replace=new MenuItem("替换"); MenuItem Seek=new MenuItem("查找");

//首要添加组件的情况

mb.add(file);mb.add(edit);mb.add(pattern);mb.add(time);mb.add(help);

file.add(renew);file.addSeparator();file.add(open);time.add(tdate);

file.addSeparator(); file.add(exit);file.addSeparator();file.add(save);

edit.add(copy); edit.addSeparator();edit.add(paste);edit.addSeparator();edit.add(cut);

pattern.add(Font); pattern.add(Replace);

pattern.add(Seek);help.add(helptopic);

//给必要的组件加上监听器

renew.addActionListener( this);tdate.addActionListener(this);

open.addActionListener(this); save.addActionListener(this);exit.addActionListener(this);

cut.addActionListener(this);copy.addActionListener(this);paste.addActionListener(this);

ce1.addItemListener(this);ce2.addItemListener(this);ce3.addItemListener(this);

//添加必要的组件

add(ta,"Center");ta.setBackground(new Color(249,255,234));

setSize(700,500);

setVisible(true);

this.validate() ;

}

public void itemStateChanged(ItemEvent e) {

if (ce2.getSelectedItem().equals("粗体"))

{ k=1;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}

if (ce2.getSelectedItem().equals("斜体"))

{ k=2;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}

if (ce2.getSelectedItem().equals("常规"))

{ k=3;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}

}

public void actionPerformed(ActionEvent e)

{

if(e.getActionCommand().equals("新建"))

{System.out.println("new ");

ta.setText("");}

if(e.getActionCommand().equals("退出"))

{ System.exit(0);}

try

{

if(e.getActionCommand().equals("打开"))

openText();

if(e.getActionCommand().equals("保存"))

saveText();

}catch(IOException e1){}

if(e.getActionCommand().equals("复制"))

{ str=ta.getSelectedText();}

if(e.getActionCommand().equals("粘贴"))

{ ta.insert(str,ta.getCaretPosition());}

if(e.getActionCommand().equals("剪切"))

{str=ta.getSelectedText();ta.replaceRange("",ta.getSelectionStart(),ta.getSelectionEnd());

}

if(e.getActionCommand().equals("字体"))

{dialog.setVisible(true);}

if(e.getActionCommand().equals("主题"))

{dialog1.setVisible(true);}

if(e.getActionCommand().equals("颜色"))

{

Color clr=JColorChooser.showDialog(this,"颜色对话框",null);

ta.setForeground(clr);

}

if(e.getSource()==btn2)

dialog.setVisible(false);

if(e.getSource()==btn1)

{

if(k==1)

{ ta.setFont(new Font(st1,Font.BOLD,Integer.parseInt(st2)));}

if(k==2)

{ ta.setFont(new Font(st1,Font.ITALIC,Integer.parseInt(st2)));}

if(k==3)

{ ta.setFont(new Font(st1,Font.PLAIN,Integer.parseInt(st2)));}

dialog.setVisible(false);

}

//if (e.getActionCommand().equals("日期/时间"))

//ta.setText(ta.getText()+""+date);

if(e.getActionCommand().equals("日期/时间"))

{

Calendar c1 =Calendar.getInstance();

int y = c1.get(Calendar.YEAR);

int m = c1.get(Calendar.MONTH);

int d = c1.get(Calendar.DATE);

int h = c1.get(Calendar.HOUR);

int m1 = c1.get(Calendar.MINUTE);

int m2 = m+1;

ta.setText(ta.getText()+""+(y+"年"+m2+"月"+d+"日"+h+":"+m1));

}

}

public void openText() throws IOException

{

FileDialog fd=new FileDialog(this,"打开文件对话框",FileDialog.LOAD);

fd.setVisible(true);FileInputStream fis=new FileInputStream(fd.getDirectory()+fd.getFile());

ta.setText("");

int n=0;

while((n=fis.read())!=-1)

ta.append(""+(char)n);

fis.close();

}

public void saveText() throws IOException

{

FileDialog fd=new FileDialog(this,"打开文件对话框",FileDialog.SAVE);

fd.setVisible(true);

FileOutputStream out=new FileOutputStream(fd.getDirectory()+fd.getFile()+".txt");

String str=ta.getText();

String str1=ta.getText();

for(int n=0;nstr.length();n++)

out.write((byte)str.charAt(n));

out.close();

}

public static void main(String[] args)

{

Editor f=new Editor(" 记事本程序");

//添加时间代码

Date date=new Date();

System.out.print(date);

/*Calendar now=Calendar.getInstance();

int year=now.get(Calendar.YEAR);

int month=now.get(Calendar.MONTH)+1;

int day=now.get(Calendar.DATE);

System.out.print(year+"年"+month+"月"+day+"日");

int week=now.get(Calendar.DAY_OF_WEEK);

String str="日一二三四五六";//星期1-7

int i=2*(week-1);

System.out.println("星期"+str.substring(i,i+2));//对应中文的下标*/

}

class dialog extends Dialog

{

public dialog()

{

super(dialog, "字体设置");

class Mycanvas extends Canvas

{

Toolkit tk;

Image img;

Mycanvas()

{

setSize(440,138);

tk=getToolkit();

img=tk.getImage("photo.jpg");

}

public void paint(Graphics g)

{

g.drawImage(img,5,120,440,138,this);

}

}

}

}

}

在java中怎么使用ckeditor????

一、下载ckeditor_3.6.2.zip和ckeditor-java-core-3.5.3.zip两个压缩文件,去官网上下载。

二、解压缩文件ckeditor_3.6.2.zip和ckeditor-java-core-3.5.3.zip两个文件,在ckeditor_3.6.2文件中有ckeditor文件夹;ckeditor-java-core-3.5.3中有ckeditor-java-core-3.5.3.jar、

ckeditor-java-core-3.5.3-javadoc.jar和ckeditor-java-core-3.5.3-sources.jar三个jar包。

三、我使用的是Myeclipse开发工具,新建工程,接着把ckeditor_3.6.2文件夹下的ckeditor整个复制到工程WebRoot下;然后把ckeditor-java-core-3.5.3文件夹下的三个jar包复制到WebRoot——WEB-INF——lib文件夹下!

注意:该版本的不需要在web.xml文件中配置servlet/servlet

四、下面写一个jsp页面来使用这个ckeditor,为了省时间,直接在index.jsp页面上写代码。

注意:要使用就必须先引入ckeditor.js文件

scripttype="text/javascript"src="ckeditor/ckeditor.js"/script

五、接下来发布工程,启动服务器,在地址栏中输入:

就可以访问了。

关于javafeditor和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-29,除非注明,否则均为首码项目网原创文章,转载请注明出处。