【发布时间】:2013-12-05 09:32:19
【问题描述】:
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);
}
}
【问题讨论】:
-
请在您的问题上投入一些精力。不要只发布“错误”和代码墙——告诉我们您的问题的一些细节。对不起,但这个问题是懒惰的终极。请证明这是错误的。
-
您遇到了什么类型的错误?
-
您使用了错误的标签。只需使用代码按钮
{}进行格式化。不要让它变得粗体。我不打算清理那个了,我想早点睡觉。 -
再次查看How to write Mouse Listeners 并执行
MouseListener接口指定的合约。您也不妨看看Interfaces tutorial -
我们已经告诉您您在上一个已结束的问题中遇到的问题是什么,但您只是选择忽略它。为什么?如果您只是忽略帮助,为什么还要尝试提供帮助?再次查看@MadProgrammer 的链接,您的类必须实现它声明要实现的任何接口的所有方法。你的实现了 none 的 MouseListener 方法。