你看看下面的程序段:
下面是初始化部分: //init JButton...
reloadWebXML  = new JButton ("Reload Web.xml file");
//init reloadWebXML button mouse click event...
    reloadWebXML.addActionListener (new java.awt.event.ActionListener ()
    {
       public void actionPerformed (ActionEvent e)
       {
         //Add crlf to web.xml file...
         modifyXMLFile (webXMLPath.getText (), true);
//Remove crlf from web.xml file at the end...
modifyXMLFile (webXMLPath.getText (), false); JOptionPane.showMessageDialog (null, "OK!");
       }
    });modifyXMLFile是另外一个方法;

解决方案 »

  1.   

    同意
    killme2008(我不会编程)
      

  2.   

    除了 Leemaasn(他这家伙不怀好意 :P) 就没人会了吗?失望中。
      

  3.   

    你想“按”什么?swing里面不仅仅只有 JButton能按的。其实大家的看法一致,按钮是个小事情,要学会自己找资料,自己解决自己遇到的难题,这样才能提高。
      

  4.   

    ps: 
        “java高手请进”,这样的标题会很让人反感的。
      

  5.   

    每个按钮这样:JButton newBtn = new JButton("新增");
    newBtn.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
    //中间加你要干的事情;
    //Exp:c13.setText("改变了!!!");
          }
          }
    );
    其他按钮类似。
      

  6.   

    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;public class GUIDemo2
    {
            public static void  main(String[] args)
            {
            //图形界面的屏幕显示部分
            JFrame frame=new JFrame("例子");
            final JTextField Text=new JTextField("学好JAVA用处大!!!");
            JButton Button1 =new JButton("按扭");
            JButton Button2 =new JButton("退出");
            final JCheckBox cb=new JCheckBox();
            frame.getContentPane().setLayout(new FlowLayout( ));
            frame.getContentPane().add(Text);
            frame.getContentPane().add(Button1);
            frame.getContentPane().add(Button2);
            frame.getContentPane().add(cb);
            frame.pack();
            frame.setVisible(true);
            Text.setEditable(false);        //图形界面的事件处理部分
            Button1.addActionListener(new ActionListener() { //内隐类
              public void actionPerformed(ActionEvent e) {
                Text.setText("这是JTextField和JButton的一个示例");
              }
            });
            Button2.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent f) { //actionPerformed不可更改
                System.exit(0);
              }
            });
            cb.addActionListener(new ActionListener(){
              public  void  actionPerformed(ActionEvent f){
                //cb.setBorderPainted(true);
                //cb.setBorderPaintedFlat(true);
                //cb.setBackground(Color.red);
                cb.setForeground(Color.red);          }
            });
            frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                System.exit(0);
              }
            });
          }
        }