Tôi đã lập trình một số chương trình và tôi đã biên soạn một số chương trình, nhưng biết tôi đã lập trình Trình nhắn tin trò chuyện. Và khi tôi biên dịch Máy chủ hoặc Máy khách, tôi luôn gặp lỗi từ javac. "lỗi: không thể tìm thấy biểu tượng". Và bởi cả hai lỗi là tại các nhà xây dựng của lớp khác làm thế nào nên xây dựng ở đó. dụ:Lỗi Javac: Không thể tìm thấy Symbol
Chat.java:11 error: cannot find symbol
Frame frm = new Frame();
^
Symbol: class Frame
location: class Chat
Chat.java:11 error: cannot find symbol
Frame frm = new Frame();
^
Symbol: class Frame
location: class Chat
CHỦ
package main;
public class Chat {
public static void main(String args[]){
Frame frm = new Frame();
frm.setLayout(null);
frm.setVisible(true);
frm.setSize(800, 600);
frm.setResizable(false);
// a loop who wait for an true boolean
frm.abfrage();
while(true){
frm.readChat();
}
}
}
KHUNG lớp mà không cần chức năng (chỉ Constructor)
package main;
//action + windowlistener + event import;
//Inputreader,writer,reader and IOException import;
//socket import + exception;
//.. there are some Javax.swing imports;
public class Frame extends JFrame {
Client client;
JPanel textPanel;
static boolean start;
static JTextArea messengerText;
JTextField writenText;
JTextField portInfo;
JTextField hostInfo;
JButton senden;
JButton connect;
public String writenString;
public String chatString;
int port;
String adress;
public Frame(){
super("Chat by lionlak");
// this.client = client;
client = new Client("localhost",5483);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
//Deklarationen
start = false;
writenString = "Hallo vom Client";
chatString = "Chat by lionlak";
//Konstruktoren
//JPanel
textPanel = new JPanel();
//JTextField
writenText = new JTextField();
portInfo = new JTextField();
hostInfo = new JTextField();
messengerText = new JTextArea();
//JButton
senden = new JButton("SENDEN");
connect = new JButton("Connect");
//Listener
senden.addActionListener(new actionListener());
connect.addActionListener(new actionListener());
addWindowListener(new windowHandler());
//Eigenschaften
//JPanel
textPanel.setLayout(null);
textPanel.setBounds(10,150,490,780);
//JTextField
portInfo.setBounds(120,10,100,40);
portInfo.setText("5483");
hostInfo.setBounds(10, 10, 100, 40);
hostInfo.setText("127.0.0.1");
messengerText.setBounds(0,0,380,290);
messengerText.setText(chatString);
writenText.setBounds(0, 310, 280, 100);
writenText.setText("Deine Nachricht!");
//JButton
senden.setBounds(290, 310, 100, 40);
connect.setBounds(230, 10, 100, 40);
//Add
textPanel.add(messengerText);
textPanel.add(writenText);
textPanel.add(senden);
add(hostInfo);
add(portInfo);
add(connect);
add(textPanel);
}
nhập java.awt.Frame; –
Bạn cần thêm thông tin. Ví dụ, mã sử dụng 'Frame'. Tại thời điểm này, hầu hết mọi người cho rằng bạn đang đề cập đến 'java.awt.Frame', tuy nhiên có thể bạn không có. –
khuyến nghị của tôi là: sử dụng một IDE như Eclipse, nó sẽ giúp ích. và rõ ràng là nghiên cứu đủ Java để hiểu cơ sở. – logoff