I've tried the sublime text forums but got nothing there. I wrote a simple Java GUI program (sorry for my bad definition, I'm ignorant) which imports those packages:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.swing.*;
import java.swing.border.*;
But when I hit the CTRL + B combination to build and run the program, I get the following errors:
AddressBook.java:4: error: package java.swing does not exist
import java.swing.*;
^
AddressBook.java:5: error: package java.swing.border does not exist
import java.swing.border.*;
^
AddressBook.java:7: error: cannot find symbol
public class AddressBook extends JFrame {
^
symbol: class JFrame
AddressBook.java:21: error: cannot find symbol
private JTextField jtfName = new JTextField(NAME_SIZE);
^
symbol: class JTextField
location: class AddressBook
Can anyone help me?
You should import javax.swing.*
rather than java.swing.*
Also, you don't need to then import swing.border
, as swing.*
will pull in all of the contents of the swing
package.
But really, I would recommend you to download IntelliJ IDEA community edition to make your life much easier =)
The correct import statements would be:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
Notice "javax" vs "java".
This is why using a good IDE is very helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.