I implemented ActionListener in my java class, but when I tried to auto-import (Shift+Alt+O), it gave this error:
Running the contributed command: '_vscode_delegate_cmd_ksicrwzq' failed.
The whole code is here:
import javax.swing.JFrame;
import javax.swing.JTextField;
public class myframe extends JFrame implements ActionListener{
myframe(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
this.pack();
this.setVisible(true);
JTextField text = new JTextField();
text.setPreferredSize(new Dimension(250,40));
}
I was having similar problem that is VS Code not showing imports for java.awt package as can be seen here.
.
After a lot of research, I came to this link explaining about Working with GUI in VS code.
Follow the following steps:
You can open command pallete by pressing Ctrl + Shift + P or ⌘ + Shift + P for mac Users.
Java: Help Center
Students tab:Navigate to the Student's tab in Java: Help Center
Enable AWT Development
This procedure solved my issue and now VS Code is providing suggestions for java.awt package.
See similar issue report in github: Click the bulbs to Organize imports throws the error.
After Cleaning Java Language Server Workspace from Command Palette, hovering over the code then use Quick Fix to import needed jars instead of keyboard shortcuts. Then the error wouldn't happen again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With