frame2.java

来自「网上虚拟社区」· Java 代码 · 共 278 行

JAVA
278
字号


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.Font;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.Naming;

public class Frame2 extends JFrame implements ActionListener{

	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 JLabel jLabel2 = null;

	private JLabel jLabel3 = null;
	
	private String name = null;
	
	private String password = null;
	
	private String genere = null;
	
	private String url = null;
	
	private CommunityServerInterface thecommunity;  //  @jve:decl-index=0:
	private Virtualperson  person;
	

	/**
	 * This is the default constructor
	 */
	public Frame2() {
		super();
		initialize();
	}
	
	public Frame2(String Name, String Password, String Genere,String Url) {
		super();
		name = Name;
		password = Password;
		genere = Genere;
		url = Url;
//		initializeRMI(url);
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(500, 477);
		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) {
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(239, 308, 190, 30));
			jLabel3.setText("如果你是开发公司,欢迎进入:");
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(5, 310, 184, 26));
			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);
			jContentPane.add(jLabel3, 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(this);
		}
		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(this);
		}
		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(this);
		}
		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(this);
		}
		return jButton3;
	}

	/**
	 * This method initializes jButton4	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton4() {
		if (jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setBounds(new Rectangle(59, 376, 104, 33));
			jButton4.setText("软件销售");
			jButton4.addActionListener(this);
		}
		return jButton4;
	}

	/**
	 * This method initializes jButton5	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton5() {
		if (jButton5 == null) {
			jButton5 = new JButton();
			jButton5.setBounds(new Rectangle(299, 376, 105, 34));
			jButton5.setText("软件开发");
			jButton5.addActionListener(this);
		}
		return jButton5;
	}
	
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == jButton){
//			this.setVisible(false);
		    Frame7 frame =new Frame7(name, password,genere,url);
//		    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    frame.setVisible(true);	
		}
		else if(e.getSource() == jButton1){
		    Frame5 frame =new Frame5(name,url);
//		    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    frame.setVisible(true);	
		}
		else if(e.getSource() == jButton2){
		    Frame8 frame =new Frame8(name, password,genere,url);
//		    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    frame.setVisible(true);	
		}
		else if(e.getSource() == jButton3){
		    Frame3 frame =new Frame3(name, password,genere,url);
//		    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    frame.setVisible(true);	
		}
		else if(e.getSource() == jButton4){
			if(genere.equals("VeditionCompany")){
		      Frame9 frame =new Frame9(name, password,genere,url);
//		      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		      frame.setVisible(true);	
			}
			else
				 JOptionPane.showMessageDialog(null,"Sorry you are not a veditioncompany!","Genere error",JOptionPane.ERROR_MESSAGE);	
		}
		else if(e.getSource() == jButton5){
			if(genere.equals("EmpolderCompany")){
		        Frame10 frame =new Frame10(name, password,genere,url);
//		        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		        frame.setVisible(true);	
			}
			else
				JOptionPane.showMessageDialog(null,"Sorry you are not a empoldercompany!","Genere error",JOptionPane.ERROR_MESSAGE);	
		}
			
	}
	
/*	protected boolean initializeRMI(String url){
		if(url.equals("default"))
			url = "";
		url = "rmi://"+url+"/";
		try{
			thecommunity = (CommunityServerInterface)Naming.lookup(url+"CommunityServerInterfaceImpl");
			System.out.println("Server objecct "+thecommunity+" found");
			return true;
		}
		catch(Exception ex){
			System.out.println(ex);
			JOptionPane.showMessageDialog(null,"Please enter right ID!","ID error",JOptionPane.ERROR_MESSAGE);
			return false;
		}
	}*/

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

⌨️ 快捷键说明

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