⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 info.java

📁 用户需要注册
💻 JAVA
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.Toolkit;
//查看个人资料
public class Info extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel userAccountInfo = null;

	private JLabel username = null;

	private JLabel account = null;

	private JLabel id = null;

	private JLabel question = null;

	private JButton ok = null;

	private JButton change = null;

	private JLabel username1 = null;

	private JLabel id1 = null;

	private JLabel account1 = null;

	private JLabel question1 = null;
	
	private String jing = new String("");
	private String id2 = new String("");
	private String account2 = new String("");
	private String question2 = new String("");

	private JLabel jLabel = null;

	/**
	 * This is the default constructor
	 */
	public Info() {
		super();
		initialize();
	}
	public Info(String jing) {
		super();
		this.jing = jing;
		PrintWriter toServer = null;
		try
		{
			Socket socket;
			socket = new Socket("localhost",2000);
			toServer = new PrintWriter(socket.getOutputStream(),true);
			toServer.println(6);
			toServer.println(jing);
			try
			{
				
				ServerSocket serverSocket = new ServerSocket(2013);
				
				Socket  fromServer = serverSocket.accept();
				
				BufferedReader isFromServer = new BufferedReader(new InputStreamReader(fromServer.getInputStream()));
				
				id2 = new String(isFromServer.readLine());
				account2 = new String(isFromServer.readLine());
				question2 = new String(isFromServer.readLine());
				serverSocket.close();
			}
			catch(IOException ex)
			{
				System.err.println(ex);
			}
			//socket.close();
		}
		catch(IOException ex)
		{
			System.err.println(ex);
		}
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(325, 317);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pic/info.png")));
		this.setContentPane(getJContentPane());
		this.setTitle("账号信息");
		//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(false);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			question1 = new JLabel();
			question1.setBounds(new Rectangle(195, 200, 80, 20));
			question1.setText(question2);
			//question1.setEnabled(false);
			question1.setForeground(Color.black);
			account1 = new JLabel();
			account1.setBounds(new Rectangle(195, 160, 80, 20));
			account1.setText(account2);
			//account1.setEnabled(false);
			account1.setForeground(Color.black);
			id1 = new JLabel();
			id1.setBounds(new Rectangle(195, 120,80, 20));
			id1.setText(id2);
			//id1.setEnabled(false);
			id1.setForeground(Color.black);
			username1 = new JLabel();
			username1.setBounds(new Rectangle(195, 80, 80, 20));
			//username1.setEnabled(false);
			username1.setForeground(Color.black);
			username1.setText(jing);
			question = new JLabel();
			question.setBounds(new Rectangle(50, 200, 85, 20));
			
			question.setText(" 密码提示问题");
			id = new JLabel();
			id.setBounds(new Rectangle(50, 120, 85, 20));
			id.setText("   身份证号码");
			account = new JLabel();
			account.setBounds(new Rectangle(50, 160, 85, 20));
			account.setText("     账户号码");
			username = new JLabel();
			username.setBounds(new Rectangle(50, 80, 85, 20));
			username.setText("       用户名");
			userAccountInfo = new JLabel();
			userAccountInfo.setBounds(new Rectangle(28, 30, 90, 40));
			userAccountInfo.setIcon(new ImageIcon(getClass().getResource("/pic/info.gif")));
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(userAccountInfo, null);
			jContentPane.setBackground(Color.white);
			jContentPane.add(username, null);
			jContentPane.add(account, null);
			jContentPane.add(id, null);
			jContentPane.add(question, null);
			jContentPane.add(getOk(), null);
			jContentPane.add(getChange(), null);
			jContentPane.add(username1, null);
			jContentPane.add(id1, null);
			jContentPane.add(account1, null);
			jContentPane.add(question1, null);
			jContentPane.add(getJLabel(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes ok	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getOk() {
		if (ok == null) {
			ok = new JButton();
			ok.setBounds(new Rectangle(192, 238, 65, 30));
			ok.setIcon(new ImageIcon(getClass().getResource("/pic/ok.gif")));
			ok.setBorderPainted(false);
			
			ok.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					sign_out();
				}
				});
		}
		return ok;
	}
	
	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private void sign_out()
	{
		this.dispose();
	}
	
	/**
	 * This method initializes change	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getChange() {
		if (change == null) {
			change = new JButton();
			change.setBounds(new Rectangle(62, 238, 65, 30));
			change.setIcon(new ImageIcon(getClass().getResource("/pic/change.gif")));
			change.setBorderPainted(false);
			change.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {	
					changeFrame ch=new changeFrame(jing);
					ch.setVisible(true);
					sign_out();
				}
				});
		}
		return change;
	}
	/**
	 * This method initializes jLabel	
	 * 	
	 * @return javax.swing.JLabel	
	 */
	private JLabel getJLabel() {
		if (jLabel == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(0, 0, 316, 284));
			jLabel.setIcon(new ImageIcon(getClass().getResource("/pic/background4.jpg")));
			jLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
		}
		return jLabel;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -