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

📄 frame8.java

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


import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Font;
import javax.swing.JButton;

import java.rmi.Naming;
import java.util.Vector;



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

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JScrollPane jScrollPane = null;

	private JTable jTable = null;
	
//	private String[] columnNames = {"Dishname","price","totalnum","Serveredbeforeyou"};

	private JLabel jLabel = null;

	private JButton jButton = null;

	private JButton jButton1 = null;

	private JButton jButton2 = 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;

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

	
	public Frame8(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("pin");
        
		initializeRMI();
        
        try{
        	data = thecommunity.finddatabase("menu",4,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(633, 564);
		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(6, 0, 446, 50));
			jLabel.setIcon(new ImageIcon(getClass().getResource("/ball.jpg")));
			jLabel.setFont(new Font("Dialog", Font.BOLD, 14));
			jLabel.setText("欢迎您来网上茶餐馆订餐,您的支持是对我们最大的鼓励。");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJScrollPane(), null);
			jContentPane.add(jLabel, null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(getJButton1(), null);
			jContentPane.add(getJButton2(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new Rectangle(14, 48, 612, 421));
			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);
		}
		return jTable;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(106, 489, 93, 31));
			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(413, 490, 93, 30));
			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(261, 491, 86, 29));
			jButton2.setText("更新数据");
			jButton2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					jButton2ActionPerformed(evt);
				}
			});
		}
		return jButton2;
	}
	
	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 jButton1ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton1.actionPerformed, event=" + evt);
		this.setVisible(false);
	}

	private void jButton2ActionPerformed(ActionEvent evt) {
//		System.out.println("jButton2.actionPerformed, event=" + evt);
        try{
        	data = thecommunity.finddatabase("menu",4,null);
        }
        catch(Exception ex){
        	System.out.println(ex);
        	JOptionPane.showMessageDialog(null,"The internet is busy,please come letter!","Link error",JOptionPane.ERROR_MESSAGE);
        }
        tbmodel = new TbModel(data,titles);
		jTable.setModel(tbmodel);
		jTable.updateUI();
	}

	private void jButtonActionPerformed(ActionEvent evt) {
//		System.out.println("jButton.actionPerformed, event=" + evt);
		int[] rows = jTable.getSelectedRows();
		int   num = rows.length;
		String[] dishes = new String[num];
		double[] prices = new double[num];
		double money = 0;
		for(int i=0;i<num;i++){
			dishes[i] = (String)tbmodel.getValueAt(rows[i], 0);
			prices[i] = Double.valueOf((String)tbmodel.getValueAt(rows[i], 1));
			money += prices[i];
		}
		
		Frame12 frame = new Frame12(name,url,money,dishes);
		frame.setVisible(true);
	}

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

⌨️ 快捷键说明

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