import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JFrame;
public class Profile extends JFrame implements ActionListener, MouseLIstener{
JLabel home = new JLabel("Home");
JLabel pro = new JLabel("Profile");
JTextField search = new JTextField("");
JButton update = new JButton("Update Info");
ImageIcon log = new ImageIcon("mini.png");
JLabel logo = new JLabel(log, JLabel.CENTER);
ImageIcon ban = new ImageIcon("cover.jpg");
JLabel bann = new JLabel(ban, JLabel.CENTER);
ImageIcon ppic = new ImageIcon("Koala.jpg");
JLabel profile = new JLabel(ppic, JLabel.CENTER);
ImageIcon menu1 = new ImageIcon("fbMenu.png");
JLabel menu = new JLabel(menu1, JLabel.CENTER);
Container c;
Connection con;
Statement st;
ResultSet rs;
int ctr;
public Profile() {
Image icon = Toolkit.getDefaultToolkit().getImage("fb.png");
setIconImage(icon);
this.setTitle("Profile");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setLayout(null);
this.setSize(600, 500);
this.setLocationRelativeTo(null);
c=this.getContentPane();
c.setLayout(null);
this.add(update);
c.add(profile);
c.add(logo);
c.add(search);
c.add(home);
c.add(pro);
c.add(menu);
c.add(bann);
profile.setBounds(20, 150, 150, 150);
bann.setBounds(0, 0, 600, 200);
menu.setBounds(0, 0, 600, 40);
home.setBounds(360, 10, 35, 25);
pro.setBounds(410, 10, 40, 25);
update.setBounds(300, 160, 110, 35);
search.setBounds(90, 10, 230, 25);
logo.setBounds(60, 10, 25, 25);
update.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
Object o = e.getSource();
if(o==update)
{
Update j= new Update();
j.setVisible(traue);
this.setVisible(false);
j.setVisible(true);
}
}
public static void main(String[] args) {
Profile pr = new Profile();
pr.setVisible(true);
}
}
答案 0 :(得分:2)
从下面的代码:
public class Profile extends JFrame implements ActionListener, MouseLIstener{
您输入错误的MouseListener名称为 MouseLIstener 。
更改
MouseLIstener
到
MouseListener
然后在下面添加无实现方法,它将适用于您的程序。
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}