eclipse 圖形化界面跳轉實例,附代碼

頁面跳轉實例//////////////////////////////////////////////////////////////////////////////////////////////////////////幫助理解系列

加粗感謝小華同學!

1

2

跳轉成功/////////////

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class t001 {

	private JFrame frame;
	static t001 window;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
					window = new t001();
					window.frame.setVisible(true);
	}

	/**
	 * Create the application.
	 */
	public t001() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JButton btnNewButton = new JButton("New button");
		btnNewButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				window.frame.setVisible(false);
				t002 t2 = new t002();
			}
		});
		frame.getContentPane().add(btnNewButton, BorderLayout.CENTER);
	}

}

import java.awt.EventQueue;

import javax.swing.JFrame;

public class t002 {

	private JFrame frame;
	static t002 window;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {

					window = new t002();
					window.frame.setVisible(true);
	}

	/**
	 * Create the application.
	 */
	public t002() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
		frame.setVisible(true);
		
	}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章