JAVA...窗口的实现,有点问题帮忙指出谢谢!!

package 第12周作业;

import java.awt.*;
import javax.swing.*;

public class MyJFrame extends JFrame {
	
	private static final long serialVersionUID = 1L;

	MyJFrame(String s){
		super(s);
		setBounds(300,300,500,300);
		setVisible(true);
		MyPanel MyPanel1 = new MyPanel();
		MyPanel MyPanel2 = new MyPanel();
	    add(MyPanel1,BorderLayout.EAST);
		add(MyPanel2,BorderLayout.WEST);
		this.validate();
	}
}




package 第12周作业;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MyPanel extends JPanel implements MouseListener{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int text;
	JButton button;
	MyPanel(){
	TextField text = new TextField("殷华哲是傻逼",15);
	JButton button =  new JButton("单击我");
	button.addMouseListener(this);
	add(text);
	add(button);
	}
	public void mouseEntered(MouseEvent e) {
		//String text1 = Integer.toString(text);
		//button.setText(text1);
	}
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		//String text1 = Integer.toString(text);
		//button.setText(text1);
	}
	public void mousePressed(MouseEvent e) {
		//String text1 = Integer.toString(text);
		//button.setText(text1);
	}
	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		//String text1 = Integer.toString(text);
		//button.setText(text1);
	}
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		String text1 = Integer.toString(text);
		button.setText(text1);
	}
}











package 第12周作业;

public class Text {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new MyJFrame("我的窗口");
	}
}


 

你可能感兴趣的:(JAVA...窗口的实现,有点问题帮忙指出谢谢!!)