getSource() && getActionCommand

class Action implements ActionListener
{
    public static String text_str;
    public Action ()
    {}
    
    public void actionPerformed(ActionEvent e)


    {
          
              JTextField text=(JTextField)e.getSource();
              //String name=e.getActionCommand();
              text_str =text.getText();
              System.out.println(text_str);
              //System.out.println(name);
            
               
      }
}

你可能感兴趣的:(getSource)