首页编程java编程java记事本是什么类型?电脑上的记事本是什么格式的

java记事本是什么类型?电脑上的记事本是什么格式的

编程之家2023-10-1286次浏览

今天给各位分享java记事本是什么类型的知识,其中也会对电脑上的记事本是什么格式的进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

java记事本是什么类型?电脑上的记事本是什么格式的

电脑上的记事本是什么格式的

最简答的格式,或者说没有格式--相对于专业的字处理软件。

用于打字、编辑网页,也用于系统及软件动态链接数据库的应用和打开方式。

在windows操作系统中,有一个记事本程序。

java记事本是什么类型?电脑上的记事本是什么格式的

只要点击开始--附件--记事本,就打开了。

它的作用如下:

编辑文本信息.

java记事本是什么类型?电脑上的记事本是什么格式的

可以用来写编程语言的源代码.比如你用C语言写了一段代码,然后把该文件的扩展名改成.C,然后在TC2.0下可以直接执行.同样,JAVA的源文件也可以通过同样操作实现.

修复文件

隐藏文件

如果你不想单独使用某些加密软件,又懒得去记那些繁琐的密码,那么使用记事本也可以作为一种选择。我们先在“记事本”里面输入需要保密的内容,然后选择“文件/保存”命令,在“保存类型”中选择“所有文件(*.*)”。

编辑系统文件

如果你已经从报刊上面知道某个系统文件(如ini文件、inf文件、reg文件)可以修改,从而让自己的爱机跑得更欢,那么你可以使用“记事本”来完成这个工作。

简单记事本的java程序代码

天啊,冖_Na0为什么会有我编的记事本代码呢???呵呵……你肯定是“请教”过我的吧??

呵呵……我自己编了一个,不过呢,没有windows那么多的功能啊。

涉及到两个文件:

第一个文件中的代码:

packageMyProject;

importjava.awt.BorderLayout;

importjavax.swing.JPanel;

importjavax.swing.JFrame;

importjava.awt.Dimension;

importjavax.swing.JMenuBar;

importjavax.swing.JMenu;

importjavax.swing.JMenuItem;

importjavax.swing.JLabel;

importjava.awt.Rectangle;

importjavax.swing.JTextArea;

importjavax.swing.JScrollPane;

importjava.awt.datatransfer.*;

importjava.io.*;

publicclassMainFrameextendsJFrame{

privatestaticfinallongserialVersionUID=1L;

privateJPaneljContentPane=null;

privateJMenuBarjJMenuBar=null;

privateJMenujMenu=null;

privateJMenujMenu1=null;

privateJMenujMenu2=null;

privateJMenuItemjMenuItem=null;

privateJMenuItemjMenuItem1=null;

privateJMenuItemjMenuItem2=null;

privateJMenuItemjMenuItem3=null;

privateJLabeljLabel=null;

privateJScrollPanejScrollPane=null;

privateJTextAreajTextArea=null;

privateJMenuItemjMenuItem4=null;

privateJMenuItemjMenuItem5=null;

privateJMenuItemjMenuItem6=null;

privateJMenuItemjMenuItem7=null;

privatestaticMainFramemyMainFrame=null;

privatestaticStringtextstr="";///用于记录文本文件的路径

privateFilemyFile=null;

privateFileReadermyrder=null;

privateFileWritermywr=null;

/**

*Thisisthedefaultconstructor

*/

publicMainFrame(){

super();

initialize();

}

/**

*Thismethodinitializesthis

*

*@returnvoid

*/

privatevoidinitialize(){

this.setSize(412,350);

this.setJMenuBar(getJJMenuBar());

this.setContentPane(getJContentPane());

this.setTitle("JFrame");

this.addWindowListener(newjava.awt.event.WindowAdapter(){

publicvoidwindowActivated(java.awt.event.WindowEvente){

if(!textstr.equals("")){

try{

myFile=newFile(textstr);

if(!myFile.exists()){

myFile.createNewFile();

}

myrder=newFileReader(myFile);

char[]mychar=newchar[(int)myFile.length()];

myrder.read(mychar);

Stringtmp=newString(mychar);

jTextArea.setText(tmp);

myrder.close();

}

catch(Exceptionee){

ee.printStackTrace();

}

}

}

publicvoidwindowClosing(java.awt.event.WindowEvente){

System.exit(0);

}

});

this.setVisible(true);

myMainFrame=this;

}

/**

*ThismethodinitializesjContentPane

*

*@returnjavax.swing.JPanel

*/

privateJPanelgetJContentPane(){

if(jContentPane==null){

jLabel=newJLabel();

jLabel.setBounds(newRectangle(15,18,65,18));

jLabel.setText("文件内容:");

jContentPane=newJPanel();

jContentPane.setLayout(null);

jContentPane.add(jLabel,null);

jContentPane.add(getJScrollPane(),null);

}

returnjContentPane;

}

/**

*ThismethodinitializesjJMenuBar

*

*@returnjavax.swing.JMenuBar

*/

privateJMenuBargetJJMenuBar(){

if(jJMenuBar==null){

jJMenuBar=newJMenuBar();

jJMenuBar.add(getJMenu());

jJMenuBar.add(getJMenu1());

jJMenuBar.add(getJMenu2());

}

returnjJMenuBar;

}

/**

*ThismethodinitializesjMenu

*

*@returnjavax.swing.JMenu

*/

privateJMenugetJMenu(){

if(jMenu==null){

jMenu=newJMenu();

jMenu.setText("文件");

jMenu.add(getJMenuItem());

jMenu.add(getJMenuItem1());

jMenu.add(getJMenuItem2());

jMenu.add(getJMenuItem3());

}

returnjMenu;

}

/**

*ThismethodinitializesjMenu1

*

*@returnjavax.swing.JMenu

*/

privateJMenugetJMenu1(){

if(jMenu1==null){

jMenu1=newJMenu();

jMenu1.setText("编辑");

jMenu1.add(getJMenuItem4());

jMenu1.add(getJMenuItem5());

jMenu1.add(getJMenuItem6());

}

returnjMenu1;

}

/**

*ThismethodinitializesjMenu2

*

*@returnjavax.swing.JMenu

*/

privateJMenugetJMenu2(){

if(jMenu2==null){

jMenu2=newJMenu();

jMenu2.setText("帮助");

jMenu2.add(getJMenuItem7());

}

returnjMenu2;

}

/**

*ThismethodinitializesjMenuItem

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem(){

if(jMenuItem==null){

jMenuItem=newJMenuItem();

jMenuItem.setText("打开");

jMenuItem.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

MainFrame.this.myMainFrame.setEnabled(false);

SelectTextFilemysl=newSelectTextFile();

mysl.setVisible(true);

}

});

}

returnjMenuItem;

}

/**

*ThismethodinitializesjMenuItem1

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem1(){

if(jMenuItem1==null){

jMenuItem1=newJMenuItem();

jMenuItem1.setText("关闭");

jMenuItem1.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

try{

myFile=null;

}

catch(Exceptionee){

ee.printStackTrace();

}

jTextArea.setText("");

}

});

}

returnjMenuItem1;

}

/**

*ThismethodinitializesjMenuItem2

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem2(){

if(jMenuItem2==null){

jMenuItem2=newJMenuItem();

jMenuItem2.setText("保存");

jMenuItem2.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

try{

Stringtmp=jTextArea.getText();

char[]mychar=tmp.toCharArray();

myFile.delete();

myFile.createNewFile();

mywr=newFileWriter(myFile);

mywr.write(mychar);

mywr.close();

}

catch(Exceptionee){

ee.printStackTrace();

}

}

});

}

returnjMenuItem2;

}

/**

*ThismethodinitializesjMenuItem3

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem3(){

if(jMenuItem3==null){

jMenuItem3=newJMenuItem();

jMenuItem3.setText("退出");

jMenuItem3.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

System.exit(0);

}

});

}

returnjMenuItem3;

}

/**

*ThismethodinitializesjScrollPane

*

*@returnjavax.swing.JScrollPane

*/

privateJScrollPanegetJScrollPane(){

if(jScrollPane==null){

jScrollPane=newJScrollPane();

jScrollPane.setBounds(newRectangle(15,46,371,225));

jScrollPane.setViewportView(getJTextArea());

}

returnjScrollPane;

}

/**

*ThismethodinitializesjTextArea

*

*@returnjavax.swing.JTextArea

*/

privateJTextAreagetJTextArea(){

if(jTextArea==null){

jTextArea=newJTextArea();

}

returnjTextArea;

}

/**

*ThismethodinitializesjMenuItem4

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem4(){

if(jMenuItem4==null){

jMenuItem4=newJMenuItem();

jMenuItem4.setText("复制");

jMenuItem4.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

MainFrame.this.setClipboardText(MainFrame.this.getToolkit().getSystemClipboard(),jTextArea.getSelectedText());

}

});

}

returnjMenuItem4;

}

/**

*ThismethodinitializesjMenuItem5

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem5(){

if(jMenuItem5==null){

jMenuItem5=newJMenuItem();

jMenuItem5.setText("剪切");

jMenuItem5.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

MainFrame.this.setClipboardText(MainFrame.this.getToolkit().getSystemClipboard(),jTextArea.getSelectedText());

jTextArea.setText(jTextArea.getText().substring(0,jTextArea.getSelectionStart()));

}

});

}

returnjMenuItem5;

}

/**

*ThismethodinitializesjMenuItem6

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem6(){

if(jMenuItem6==null){

jMenuItem6=newJMenuItem();

jMenuItem6.setText("黏贴");

jMenuItem6.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

try{

jTextArea.setText(jTextArea.getText().substring(0,jTextArea.getSelectionStart()));

jTextArea.setText(jTextArea.getText()+(MainFrame.this.getClipboardText(MainFrame.this.getToolkit().getSystemClipboard())));

}

catch(Exceptionee){

ee.printStackTrace();

}

}

});

}

returnjMenuItem6;

}

/**

*ThismethodinitializesjMenuItem7

*

*@returnjavax.swing.JMenuItem

*/

privateJMenuItemgetJMenuItem7(){

if(jMenuItem7==null){

jMenuItem7=newJMenuItem();

jMenuItem7.setText("关于记事本");

jMenuItem7.addActionListener(newjava.awt.event.ActionListener(){

publicvoidactionPerformed(java.awt.event.ActionEvente){

////暂无代码!!

}

});

}

returnjMenuItem7;

}

publicstaticvoidmain(Stringargs[]){

newMainFrame();

}

publicstaticMainFramegetMyMainFrame(){

returnmyMainFrame;

}

publicstaticvoidsetMyMainFrame(MainFramemyMainFrame){

MainFrame.myMainFrame=myMainFrame;

}

publicstaticStringgetTextstr(){

returntextstr;

}

publicstaticvoidsetTextstr(Stringtextstr){

MainFrame.textstr=textstr;

}

protectedstaticStringgetClipboardText(Clipboardclip)throwsException{

TransferableclipT=clip.getContents(null);//获取剪切板中的内容

if(clipT!=null){

if(clipT.isDataFlavorSupported(DataFlavor.stringFlavor))//检查内容是否是文本类型

return(String)clipT.getTransferData(DataFlavor.stringFlavor);

}

returnnull;

}

protectedstaticvoidsetClipboardText(Clipboardclip,StringwriteMe){

TransferabletText=newStringSelection(writeMe);

clip.setContents(tText,null);

}

}//@jve:decl-index=0:visual-constraint="10,10"

第二个文件中的代码:

(太长了,贴不上来)

整个效果就是实现了基本的打开、关闭、保存、退出的功能。

效果如图:

急! 安装了java,但开.java的文件却是用记事本打开!

你下载的“java”其实是jdk……是java开发工具集,有了这个你确实就能写java代码,并且编译.java文件为.class(class文件才是真正可执行的内容)

使用方法就是用任何开发工具(你用记事本打开也没问题)编写java文件,然后在后台,就是在cmd里调用命令"javac"来生成class文件,然后用命令"java"来运行class文件。

是不是觉得这样很麻烦?

所以你需要”开发工具“

SUN不提供开发工具,你应该下载个eclipse,这是很常用的java开发环境(事实上,eclipse本身也是用java写的)。

在eclipse中,你只要写java,然后它自己可以给自动生成class文件,运行它也只要点击按钮就可以了。

另外,没有任何打开方式是有java选项的,.java文件没有默认打开,除非你自定义。

哦,如果你需要的只是打开java写源代码,然后自己编译自己运行,我推荐你装一个notepad++,相当于一个进化版本的记事本,可以方便的编辑java

关于java记事本是什么类型到此分享完毕,希望能帮助到您。

java中的域是什么意思?java域是什么.java加减乘除有什么异常(加减乘除运算(Java))