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

📄 frame4.java

📁 网上虚拟社区
💻 JAVA
字号:


import java.awt.BorderLayout;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.Point;
import java.rmi.Naming;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Frame4 extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel jLabel = null;

	private JButton jButton = null;

	private JButton jButton1 = null;

	private JButton jButton2 = null;

	private JButton jButton3 = null;

	private JLabel jLabel1 = null;

	private JButton jButton4 = null;

	private JButton jButton5 = null;
	
	private String account = null;
	private String pin = null;
	private String url = null;  //  @jve:decl-index=0:
	
	private boolean isconnected = false;
	private CommunityServerInterface thecommunity;  //  @jve:decl-index=0:

	private JLabel jLabel2 = null;
	
	private DoubleDialog dialog;
	

	/**
	 * This is the default constructor
	 */
	public Frame4() {
		super();
		initialize();
	}

	
	public Frame4(String Account,String Pin ,String Url) {	
		super();
		account = Account;
		pin = Pin;
		url = Url;
		initializeRMI();
		initialize();
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(508, 431);
		this.setLocation(new Point(300, 150));
		this.setForeground(Color.magenta);
		this.setBackground(new Color(157, 103, 255));
		this.setContentPane(getJContentPane());
		this.setTitle("VirtualCommunity");
		this.setVisible(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(19, 212, 282, 29));
			jLabel2.setText("");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(46, 107, 132, 35));
			jLabel1.setText("在这里,您可以进行:");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(67, 27, 389, 70));
			jLabel.setFont(new Font("Arial Unicode MS", Font.BOLD | Font.ITALIC, 36));
			jLabel.setIcon(new ImageIcon(getClass().getResource("/login_title_01.gif")));
			jLabel.setText("欢迎来到网上银行");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLabel, null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(getJButton1(), null);
			jContentPane.add(getJButton2(), null);
			jContentPane.add(getJButton3(), null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getJButton4(), null);
			jContentPane.add(getJButton5(), null);
			jContentPane.add(jLabel2, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(60, 166, 104, 38));
			jButton.setText("余额查询");
			jButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButtonActionPerformed(evt);
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setBounds(new Rectangle(298, 165, 104, 38));
			jButton1.setText("密码修改");
			jButton1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton1ActionPerformed(evt);
				}
			});
		}
		return jButton1;
	}

	/**
	 * This method initializes jButton2	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setBounds(new Rectangle(60, 255, 103, 37));
			jButton2.setText("取款");
			jButton2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton2ActionPerformed(evt);
				}
			});
		}
		return jButton2;
	}

	/**
	 * This method initializes jButton3	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setBounds(new Rectangle(298, 256, 106, 35));
			jButton3.setText("存款");
			jButton3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton3ActionPerformed(evt);
				}
			});
		}
		return jButton3;
	}

	/**
	 * This method initializes jButton4	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton4() {
		if (jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setBounds(new Rectangle(59, 334, 104, 33));
			jButton4.setText("转账");
			jButton4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton4ActionPerformed(evt);
				}
			});
		}
		return jButton4;
	}

	/**
	 * This method initializes jButton5	
	 * 	
	 * @return javax.swing.JButton
	 */
	private JButton getJButton5() {
		if (jButton5 == null) {
			jButton5 = new JButton();
			jButton5.setBounds(new Rectangle(302, 336, 105, 34));
			jButton5.setText("退出");
			jButton5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton5ActionPerformed(evt);
				}
			});
		}
		return jButton5;
	}
	
	protected boolean initializeRMI(){
		if(isconnected) return true;
		if(url.equals("default"))
			url = "";
//		url = "rmi://"+url+"/";
		try{
			thecommunity = (CommunityServerInterface)Naming.lookup(url+"CommunityServerInterfaceImpl");
			System.out.println("Server object "+thecommunity+" found");
			isconnected = true;
			return true;
		}
		catch(Exception ex){
			System.out.println(url);
			System.out.println(ex);
			JOptionPane.showMessageDialog(null,"Please enter right ID!","ID error",JOptionPane.ERROR_MESSAGE);
			return false;
		}
	}

	private void jButton5ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton5.actionPerformed, event=" + evt);
		//TODO add your code for jButton5.actionPerformed
		this.setVisible(false);
	}

	private void jButtonActionPerformed(ActionEvent evt) {
//		System.out.println("jButton.actionPerformed, event=" + evt);
		try{
			double temp = thecommunity.findbalance(account, pin );	
			jLabel2.setText("Your Account\'s balance is ¥"+String.valueOf(temp));
//		    JOptionPane.showMessageDialog(null,"Your Account\'s balance is ¥"+String.valueOf(temp),"Find balance",JOptionPane.INFORMATION_MESSAGE);			
		}
		catch(Exception ex){
			System.out.println(ex);
			 JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);	
		}
		//TODO add your code for jButton.actionPerformed
	}

	private void jButton1ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton1.actionPerformed, event=" + evt);
		String pin0 = JOptionPane.showInputDialog(null, "Please enter new pin:",null, JOptionPane.INFORMATION_MESSAGE);
		String pin1 = JOptionPane.showInputDialog(null, "Please enter new pin again:",null, JOptionPane.INFORMATION_MESSAGE);
		if(!pin0.equals(pin1)){
			JOptionPane.showMessageDialog(null,"The pin you enter two times isn\'t the same!","Message error",JOptionPane.ERROR_MESSAGE);
		}
		else{
		   try{
			  if(thecommunity.changepin(account, pin, pin0)){
		          JOptionPane.showMessageDialog(null,"Your have succeed in changing pin!","Change pin",JOptionPane.OK_OPTION);	
		          pin =pin0;
			  }
			  else
				  JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);
		   }
		    catch(Exception ex){
			   System.out.println(ex);
			    JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);	
		   }
		}
		//TODO add your code for jButton1.actionPerformed
	}

	private void jButton2ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton2.actionPerformed, event=" + evt);
		dialog = new DoubleDialog(this,"Please enter the number of money you need:");
		dialog.setVisible(true);
		double balance = dialog.getdouble();
		if(balance<=0){
			JOptionPane.showMessageDialog(null,"Please enter righter number","Message error",JOptionPane.ERROR_MESSAGE);
		}
		else{
		   try{
			  if(thecommunity.withdraw(account, pin, balance)){
		          JOptionPane.showMessageDialog(null,"Your have succeed in withdraw money!","Withdraw money",JOptionPane.OK_OPTION);	
			  }
			  else
				  JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);
		   }
		    catch(Exception ex){
			   System.out.println(ex);
			    JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);	
		   }
		}	
		//TODO add your code for jButton2.actionPerformed
	}

	private void jButton3ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton3.actionPerformed, event=" + evt);
		dialog = new DoubleDialog(this,"Please enter the number of money you want to deposit:");
		dialog.setVisible(true);
		double balance = dialog.getdouble();
		if(balance<=0){
			JOptionPane.showMessageDialog(null,"Please enter righter number","Message error",JOptionPane.ERROR_MESSAGE);
		}
		else{
		   try{
			  if(thecommunity.deposit(account, pin, balance)){
		          JOptionPane.showMessageDialog(null,"Your have succeed in withdraw money!","Withdraw money",JOptionPane.OK_OPTION);	
			  }
			  else
				  JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);
		   }
		    catch(Exception ex){
			   System.out.println(ex);
			    JOptionPane.showMessageDialog(null,"The net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);	
		   }
		}	
		//TODO add your code for jButton3.actionPerformed
	}

	private void jButton4ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton4.actionPerformed, event=" + evt);
		//TODO add your code for jButton4.actionPerformed
//		this.setVisible(false);
	    Frame11 frame =new Frame11(account,pin,url);
//	    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    frame.setVisible(true);	
	}

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

⌨️ 快捷键说明

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