import javax.swing.*;
import java.awt.event.*;
import java.awt.*;class EditBook  
{
public static void main(String[] args) 
{
Edit e=new Edit();
e.run();
}
}
class Edit extends JFrame
{

JMenuBar jmb;
JMenu file;
JMenu compile;
JMenu tool;
JMenu help;
JMenuItem newF;
JMenuItem open;
JMenuItem save;
JMenuItem exit;
JMenuItem copy;
JMenuItem cut;
JMenuItem paste;
JMenuItem s_all;
JMenuItem color;
JMenuItem toolb;
JMenuItem toolc;
JMenuItem h;
JTextArea jta;
JDialog jd;
JPanel jp; JToolBar jtb; String message; public void run(){
jmb=new JMenuBar();
jp=new JPanel();
file=new JMenu("文件");
compile=new JMenu("编辑");
tool=new JMenu("工具");
help=new JMenu("帮助");

newF=new JMenuItem("新建");
open=new JMenuItem("打开");
save=new JMenuItem("保存");
exit=new JMenuItem("退出"); copy=new JMenuItem("Copy");
cut=new JMenuItem("Cut");
paste=new JMenuItem("Paste");
s_all=new JMenuItem("保存全部");
color=new JMenuItem("Color"); toolb=new JMenuItem("MS记事本");
toolc=new JMenuItem("MS计算器");

h=new JMenuItem("关于"); jtb=new JToolBar("MyJToolBar");
jta=new JTextArea(20,30); /*
ef.addWindowListener(new WindowAdapter(WindowEvent e){
System.exit(0);
});
*/
//文件
file.add(newF);
file.add(open); //////////如何显示文件内容
open.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jd=new JDialog(new JFrame(),"Color");
JFileChooser jfc=new JFileChooser();
String f=jfc.getName();
System.out.println(f);
jd.add(jfc);
jd.pack();
jd.setVisible(true);
}
});
file.add(save);
file.add(exit);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
//编辑
compile.add(copy);
copy.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jta.copy();
}
});
compile.add(cut);
cut.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jta.cut();
}
});
compile.add(paste);
paste.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jta.paste();
}
});
compile.add(s_all);
compile.add(color);
color.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jd=new JDialog(new JFrame(),"Color");
jd.add(new JColorChooser());
jd.pack();
jd.setVisible(true);
}
});
//工具
tool.add(toolb);
tool.add(toolc);
toolc.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Calculate cc=new Calculate();
cc.display();
}
});
//帮助
help.add(h); jmb.add(file);
jmb.add(compile);
jmb.add(tool);
jmb.add(help); jtb.add(new JButton(new ImageIcon("copy.jpg")));
jtb.add(new JButton(new ImageIcon("copy.jpg")));
jtb.add(new JButton(new ImageIcon("copy.jpg"))); jp.setLayout(new BorderLayout());
jp.add("North",jtb);
jp.add("Center",jta);
this.setJMenuBar(jmb);
this.add(jp);
this.pack();
this.setTitle("简单文本编辑器");
this.setLocation(100,150);
this.setVisible(true);
}

}

解决方案 »

  1.   

    /*
    简单计算器的功能的实现
    */
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Color;
    public class Calculate implements ActionListener {
    Frame f1;
    Panel p1=new Panel();
    Panel p2=new Panel();
    double x,y=0;
    int f=0;
    String s="";
    TextField tf1,tf2;
    Button b1,b2,b3,b4,b5,b6;
    Button b[]=new Button[11]; public static void main(String args[]) {
    (new Calculate()).display();
    } public void display(){
    f1=new Frame("窗口界面计算器");
    f1.setSize(260,150);
    f1.setLocation(320,240);
    f1.setBackground(Color.orange);
    f1.setLayout(new FlowLayout(FlowLayout.LEFT));
    f1.add(p1);
    f1.add(p2);
    p1.setLayout(new GridLayout(2,1));
    p2.setLayout(new GridLayout(2,9));
    tf1=new TextField(30);
    tf2=new TextField(30);
    tf1.setEditable(false);
    p1.add(tf1);
    tf2.setEditable(false);
    p1.add(tf2);
    for(int i=0;i<10;i++){
    String s1=""+i;
    b[i]=new Button(s1);
    p2.add(b[i]);
    b[i].addActionListener(this);
    }
    b[10]=new Button(".");
    p2.add(b[10]);
    b[10].addActionListener(this);
    b1=new Button("+");
    b2=new Button("-");
    b3=new Button("*");
    b4=new Button("/");
    b5=new Button("=");
    b6=new Button("C");
    p2.add(b1);
    p2.add(b2);
    p2.add(b3);
    p2.add(b4);
    p2.add(b5);
    p2.add(b6);
    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b4.addActionListener(this);
    b5.addActionListener(this);
    b6.addActionListener(this);
    f1.addWindowListener(new WinClose());
    f1.setVisible(true);
    }
    public void actionPerformed(ActionEvent e){
    s=s+e.getActionCommand();
    for(int i=0;i<11;i++){
    if(e.getSource()==b[i])
    tf1.setText(tf1.getText()+e.getActionCommand());
    }
    if(e.getSource()==b6){
    tf1.setText("");
    tf2.setText("");
    x=0;
    y=0;
    f=0;
    s="";
    }
    if(e.getSource()==b1){
    x=Double.parseDouble(tf1.getText());
    tf1.setText("");
    tf2.setText(""+(y+x));
    y=y+x;
    f=1;
    }
    if(e.getSource()==b2){
    x=Double.parseDouble(tf1.getText());
    tf1.setText("");
    if(y==0){
    tf2.setText(""+x);
    y=x;
    }
    else{
    tf2.setText(""+(y-x));
    y=y-x;
    }
    f=2;
    }
    if(e.getSource()==b3){
    x=Double.parseDouble(tf1.getText());
    tf1.setText("");
    if(y==0){
    tf2.setText(""+x);
    y=x;
    }
    else{
    tf2.setText(""+(y*x));
    y=y*x;
    }
    f=3;
    }
    if(e.getSource()==b4){
    x=Double.parseDouble(tf1.getText());
    tf1.setText("");
    if(y==0){
    tf2.setText(""+x);y=x;
    }
    else{
    tf2.setText(""+(y/x));
    y=y/x;
    }
    f=4;
    }
    if(e.getSource()==b5){
    x=Double.parseDouble(tf1.getText());
    if(f==1) tf1.setText(""+(y+x));
    if(f==2) tf1.setText(""+(y-x));
    if(f==3) tf1.setText(""+(y*x));
    if(f==4) tf1.setText(""+(y/x));
    y=0;
    tf2.setText(s+tf1.getText());
    }
    }
    class WinClose extends WindowAdapter{
    public void windowClosing(WindowEvent e){
    System.exit(0);
    }
    }
    }这个是我Calculate.java的源代码在运行Editplus的时候怎么在菜单栏那里出现了一个奇怪的光标
    点击那里的话 也出现了窗体标题的状况
      

  2.   

    在运行Editplus的时候怎么在菜单栏那里出现了一个奇怪的光标 
    点击那里的话 也出现了窗体标题的状况
      

  3.   

    Calculate类我贴上去了  怎么还有 问题
    在运行Editplus的时候怎么在菜单栏那里出现了一个奇怪的光标  
    点击那里的话 也出现了窗体标题的状况