我是java新手
package assigment;
import java.awt.*;
import java.sql.*;
import javax.swing.*;
public class view extends JFrame {
public static void main(String[] args) {
new view();
}
public view(){
JFrame f = new JFrame("WELCOME");
f.setSize(400, 300);
f.setVisible(true);
f.setLocationRelativeTo(null);
controller cl = new controller();
JButton btnCompany = new JButton ("COMPANY");
f.add(btnCompany);
f.setLayout(null);
btnCompany.setBounds(50, 50, 100, 50);
btnCompany.addActionListener (cl);
}
}
控制器类
package assigment;
import java.awt.event.*;
public class controller {
public static void actioncompany(ActionEvent a,view view) {
if (a.getSource() == view.btnCompany) {
System.out.print ("test");
}
}
}
问题:
不能使用
controller
类无法
btnCompany
在controller
课堂上访问