01/10/2018, 09:17
Nhờ mọi người sửa giúp lỗi ở dòng buton.addAction
import java.awt.event.ActionListener;
import javafx.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ngulam extends JFrame{
private final JLabel lable;
public void thaylable(){
lable.setText("da nhan");
}
public ngulam(){
setSize(400,200);
setResizable(false);
lable=new JLabel("hay lam");
add(lable);
JButton buton= new JButton("nhan");
add(buton,"North",1);
buton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
thaylable();
}
});
}
public static void main(String[] args){
ngulam abc=new ngulam();
abc.setVisible(true);
}
}
Bài liên quan
thay đổi thành
import java.awt.event.ActionEvent;
vẫn không được bạn ơi
Báo lỗi gì bạn ơi ? …
Bạn cần thay lại import ở trên như sau:
import java.awt.event.;
import javax.swing.;
Bạn import nhầm rồi, bạn thay đổi
import javafx.event.ActionEvent; thành java.awt.event.ActionListener;
Sai import rồi. Dùng javax, ko dùng fx.