At the moment I found one problem. I tried to add action (when I press the button, cmd.exe opened). This is my code (search is a button) And this problem appears only when I am tying to run application from my Java app (I tried make "if button pressed show message "success"):
public MainWindow (){
super("SysAdminTool");
this.setBounds(100, 100, 700 , 90);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
Container container = this.getContentPane();
container.setLayout(new GridLayout(3, 2 , 1, 1));
container.add(lcn);
container.add(icn);
container.add(lun);
container.add(iun);
container.add(empty);
search.addActionListener(new SearchEventListener ());
container.add(search);
}
class SearchEventListener implements ActionListener {
public void ActionPerformed (ActionEvent e){
Runtime.getRuntime().exec("cmd.exe");
}
}
}
Error: Error:(38, 9) java:
sys.tool.MainWindow.SearchEventListener is not abstract and does
not override abstract method actionPerformed(java.awt.event.ActionEvent)
in java.awt.event.ActionListener
public void ActionPerformed (ActionEvent e){
You have a typo. Method names in Java should NOT start with an upper case character.
When you override a method you should use:
@Override
public void actionPerformed (ActionEvent e){
Then you will get an error if your override the method incorrectly.