2013-11-21 27 views
-8
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); 
     } 

    } 
+3

請在您的問題中付出一些努力。不要只發布「錯誤」和代碼牆 - 告訴我們一些你的問題的細節。對不起,但這個問題是懶惰的終極。請證明這是錯誤的。 –

+0

你得到了什麼類型的錯誤? – Masudul

+0

您使用了錯誤的標籤。只需使用代碼按鈕「{}」進行格式化即可。不要大膽。我不打算清理那個,我想很快去睡覺。 –

回答

2

從下面的代碼:

public class Profile extends JFrame implements ActionListener, MouseLIstener{ 

您鍵入了錯誤的MouseListener名的MouseListener

變化

MouseLIstener 

MouseListener 

,然後添加以下unimplement方法,它會爲你的程序工作。

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 

    } 
相關問題