编译java源文件时说解析时已到达文件结尾

平时显示“解析时已到达文件结尾 }”时,我直接删掉最后的“}”就好了,不过这次这个“}”不应该删啊,cmd图片和源文件如下,由于字数限制,源文件还有一些内容我在图片里显示,如果哪位想要编译看看,剩下的我在追问里加
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
public class Example
{public static void main(String[] args)
{ MyFrame win=new MyFrame();
}
}
class MyFrame extends Frame implements ActionListener
{MenuBar menubar;
Menu menu1,menu2,menu3,menu4;
MenuItem copy,cut,paste,exit;
TextArea text;
Clipboard clipboard=null;
MenuShortcut shortcut1=new MenuShortcut(KeyEvent.VK_A),
shortcut2=new MenuShortcut(KeyEvent.VK_B),
shortcut3=new MenuShortcut(KeyEvent.VK_C),
shortcut4=new MenuShortcut(KeyEvent.VK_D);
MyFrame()
{menubar=new MenuBar();
menu1=new Menu("edit1");
menu2=new Menu("edit2");
menu3=new Menu("edit3");
menu4=new Menu("edit4");
copy=new MenuItem("copy");
cut=new MenuItem("cut");
paste=new MenuItem("paste");
exit=new MenuItem("exit");
copy.setShortcut(shortcut1);
cut.setShortcut(shortcut2);
paste.setShortcut(shortcut3);
exit.setShortcut(shortcut4);
menu1.add(copy);
menu2.add(cut);
menu3.add(paste);
menu4.add(exit);
menubar.add(menu1);
menubar.add(menu2);
menubar.add(menu3);
menubar.add(menu4);
setMenuBar(menubar);
text=new TextArea(50,50);
add(text,"CENTER");
copy.addActionListener(this);
cut.addActionListener(this);
paste.addActionListener(this);
exit.addActionListener(this);
setBounds(200,200,200,200);
setVisible(true);
pack();
addWindowListener(new WindowAdpater(){public void windowClosing(WindowEvent e){System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==copy)
{String s=text1.getSelectedText();
StringSelection temp=new StringSelection(s);
clipboard.setContents(temp,null);
text.append("复制了");
}
else if(e.getSource()==cut)
{String s=text.getSelectedText();
StringSelection temp=new StringSelection(s);
clipboard.setContents(temp,null);
int i=text.getSelectionStart();
int j=text.getSelectionEnd();
text.replaceRange("",i,j);
text.append("剪切了");
}
else if(e.getSource()==paste)
{Transferable content=clipboard.getContents(this);
//字数又限制了

先把你的代码格式化好吧
都看不清哪里和哪里是一个方法了
可阅读性也太差了
习惯得养好啊
写代码得习惯性都tab和空格
一定要格式化好
段落明显
这样出现这种语法错误一眼就能看出了
写代码 圆括号 中括号 花括号 双引号 单引号 什么的成对出现
养成习惯就好了追问

我把源程序的段落分出来了,你看看哪里出了问题,问题跟之前一样,还是显示“解析时已到达文件结尾 }”,另外,我最后两张图开头的一些程序是它们上一张图的结尾,为了好知道哪里跟哪里衔接


追答
//最后一张图里面少了一个}
        } else if (e.getSource() == past) {
            Transferable content = clipboard.getContents(this);
            DataFlavor flavor = DataFlavor.stringFlavor;
            if (content.isDataFlavorSupported(flavor)) {
                try {
                    String a = (String) content.getTransferData(flavor);
                    text.append(a +".黏贴好了。");
                } catche (Exception ee) {
            
                }
            }//这里少了
        } else if () {
            text.append("走了");
            System.exit(0);
        }
    }
}

温馨提示:答案为网友推荐,仅供参考
相似回答