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

📄 frame10.java

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


import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Point;
import java.rmi.Naming;
import java.util.Vector;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.Font;
import javax.swing.ImageIcon;

/**
 * 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 Frame10 extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JButton jButton = null;

	private JButton jButton1 = null;

	private JButton jButton2 = null;

	private JButton jButton3 = null;

	private JLabel jLabel = null;

	private JScrollPane jScrollPane = null;

	private JTable jTable = null;

	private String name = null;

	private String password = null;

	private String genere = null;

	private String url = null;

	private CommunityServerInterface thecommunity;

	private boolean isconnected = false;

	private Vector data;

	private Vector titles;

	private TbModel tbmodel;
	
	private int model;
	
	private DoubleDialog dialog;

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

	public Frame10(String Name, String Password, String Genere, String Url) {
		super();
		name = Name;
		password = Password;
		genere = Genere;
		url = Url;

		titles = new Vector();
		titles.add("软件名");
		titles.add("软件简介");
		titles.add("销售公司");
		titles.add("投标价格");
		titles.add("投标公司");
		// titles.add("pin");

		initializeRMI();

		try {
			data = thecommunity.finddatabase("Software", 2, null);
		} catch (Exception ex) {
			System.out.println(ex);
			JOptionPane.showMessageDialog(null,
					"The internet is busy,please come letter!", "Link error",
					JOptionPane.ERROR_MESSAGE);
		}
		// System.out.println(data);

		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(565, 551);
		this.setContentPane(getJContentPane());
		this.setTitle("开发公司");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(16, 1, 539, 44));
			jLabel.setFont(new Font("Dialog", Font.BOLD, 18));
			jLabel.setIcon(new ImageIcon(getClass().getResource("/ball.jpg")));
			jLabel.setText("欢迎您到本虚拟社区交易,我们愿意为您提供最良好的服务!");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(getJButton1(), null);
			jContentPane.add(getJButton2(), null);
			jContentPane.add(getJButton3(), null);
			jContentPane.add(jLabel, null);
			jContentPane.add(getJScrollPane(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setPreferredSize(new Dimension(34, 10));
			jButton.setSize(new Dimension(102, 34));
			jButton.setText("研发情况");
			jButton.setLocation(new Point(279, 467));
			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(13, 465, 103, 34));
			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(144, 467, 106, 33));
			jButton2.setText("投标");
			jButton2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					if(model == 0){
					jButton2ActionPerformed(evt);
					}
					else
						JOptionPane.showMessageDialog(null,
								"Please enter \"招标情况\" first", "Message error",
								JOptionPane.ERROR_MESSAGE);
				}
			});
		}
		return jButton2;
	}

	/**
	 * This method initializes jButton3
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setBounds(new Rectangle(406, 468, 103, 33));
			jButton3.setText("提交成果");
			jButton3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					if(model == 1){
						jButton3ActionPerformed(evt);
						}
						else
							JOptionPane.showMessageDialog(null,
									"Please enter \"研发情况\" first", "Message error",
									JOptionPane.ERROR_MESSAGE);
				}
			});
		}
		return jButton3;
	}

	/**
	 * This method initializes jScrollPane
	 * 
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new Rectangle(9, 46, 505, 409));
			jScrollPane.setViewportView(getJTable());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes jTable
	 * 
	 * @return javax.swing.JTable
	 */
	private JTable getJTable() {
		if (jTable == null) {
			tbmodel = new TbModel(data, titles);
			jTable = new JTable(tbmodel);
			jTable.setColumnSelectionAllowed(false);
			model = 0;
			jTable.setSelectionMode(1);
		}
		return jTable;
	}

	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 jButton3ActionPerformed(ActionEvent evt) {
		// System.out.println("jButton3.actionPerformed, event=" + evt);
		for(int value:jTable.getSelectedRows()){
			String soft = (String) tbmodel.getValueAt(value,
					0);
			String account = JOptionPane.showInputDialog(null,
					"Enter the accout you want  the money to drawin!", null,
					JOptionPane.INFORMATION_MESSAGE);
			String account1 = JOptionPane.showInputDialog(null,
					"Enter the accout again!", null,
					JOptionPane.INFORMATION_MESSAGE);
			if(account.equals(account1)){
			try{
			     thecommunity.putin(name, soft, account);
			     JOptionPane.showMessageDialog(null,
					 "We have already send out your message!", "OK",
						 JOptionPane.OK_OPTION);
			} catch (Exception ex) {
				 System.out.println(ex);
				JOptionPane.showMessageDialog(null,
					 "The internet is busy,please retry letter!",
					   	"Link error", JOptionPane.ERROR_MESSAGE);
			}
			}
			else
				JOptionPane.showMessageDialog(null,
						 "The Account you enter is wrong!",
						   	"Message error", JOptionPane.ERROR_MESSAGE);

		}
	}

	private void jButtonActionPerformed(ActionEvent evt) {
		// System.out.println("jButton.actionPerformed, event=" + evt);
		try {
			data = thecommunity.finddatabase("Software", 3, name);
		} catch (Exception ex) {
			System.out.println(ex);
			JOptionPane.showMessageDialog(null,
					"The internet is busy,please retry letter!", "Link error",
					JOptionPane.ERROR_MESSAGE);
		}
		tbmodel = new TbModel(data, titles);
		jTable.setModel(tbmodel);
		model = 1;
		jTable.updateUI();
	}

	private void jButton2ActionPerformed(ActionEvent evt) {
		// System.out.println("jButton2.actionPerformed, event=" + evt);
		for(int value:jTable.getSelectedRows()){
			String soft = (String) tbmodel.getValueAt(value,
					0);
			double price = Double.valueOf((String) tbmodel.getValueAt(value, 3));
			
			dialog = new DoubleDialog(this,"Enter the money you want to bid;");
			dialog.setVisible(true);
			double newprice = dialog.getdouble();
			if (true) {
				if (true) {
					try {
						thecommunity.bid(name, soft, newprice);
						JOptionPane.showMessageDialog(null,
								"We have already send out your message!", "OK",
								JOptionPane.OK_OPTION);
					} catch (Exception ex) {
						System.out.println(ex);
						JOptionPane.showMessageDialog(null,
								"The internet is busy,please retry letter!",
								"Link error", JOptionPane.ERROR_MESSAGE);
					}
				} else
					JOptionPane.showMessageDialog(null,
							"Your price is too high", "Money error",
							JOptionPane.ERROR_MESSAGE);
			} else
				JOptionPane.showMessageDialog(null, "Your havejust bided it!",
						"Money error", JOptionPane.ERROR_MESSAGE);
		}
	}

	private void jButton1ActionPerformed(ActionEvent evt) {
		// System.out.println("jButton1.actionPerformed, event=" + evt);
		try {
			data = thecommunity.finddatabase("Software", 2, null);
		} catch (Exception ex) {
			System.out.println(ex);
			JOptionPane.showMessageDialog(null,
					"The internet is busy,please retry letter!", "Link error",
					JOptionPane.ERROR_MESSAGE);
		}
		tbmodel = new TbModel(data, titles);
		jTable.setModel(tbmodel);
		model = 0;
		jTable.updateUI();
	}

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

⌨️ 快捷键说明

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