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

📄 softcorp.java

📁 用java编写的c/s结构的网络社区
💻 JAVA
字号:
package client;
import javax.swing.*;


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class SoftCorp extends JPanel implements ActionListener
{
	DataOutputStream dos;
	DataInputStream dis;
	JTable table1,table2,table3;
	JButton btFresh,btFinish,btFresh2,btFresh3;
	member strMeg;
	int iNum1,iNum2,iNum3;
	Object a[][];
	Object b[][];
	Object c[][];
	Object columnName1[]={"投资公司名","投资项目名","当前最低价"};
	Object columnName2[]={"投资项目名","投资公司名","本人当前报价"};
	Object columnName3[]={"投资项目名","投资公司名","本人最终报价"};
	int row1,row2,row3;
  SoftCorp(final DataOutputStream dos,final DataInputStream dis,final member strMeg)
  {
	  this.dis=dis;
	  this.dos=dos;
	  this.strMeg=strMeg;
	  a=new Object[162][3];
	  b=new Object[20][3];
	  c=new Object[20][3];
	  GridLayout gl=new GridLayout(3,1);
	  setLayout(gl);
	  JPanel p1=new JPanel(new BorderLayout());
	  table1=new JTable(a,columnName1);
	  table2=new JTable(b,columnName2);
	  table3=new JTable(c,columnName3);
	  JScrollPane jsp1=new JScrollPane(table1);
	  p1.add(jsp1);
	  table1.addMouseListener(new MouseAdapter()
		{
			public void mousePressed(MouseEvent e)
			{
				 if   (e.getClickCount()>= 2)   { 
					 byte [] data=new byte[1024];
					 String inputValue = JOptionPane.showInputDialog("请输入您的竞标价");
					 long money=Long.valueOf(inputValue);
					 row1  =   table1.rowAtPoint(e.getPoint());  
					 if(money<Long.valueOf(a[row1][2].toString()))
					 {
						 try {
								dos.writeInt(14);
								dis.read(data);
								dos.write((strMeg.getID()+"/"+a[row1][1]+"/"+money).getBytes("GB2312"));
								b[iNum2][0]=a[row1][1];
								b[iNum2][1]=a[row1][0];
								b[iNum2][2]=money;
								
							} catch (IOException e1) {
								e1.printStackTrace();
							}
					 }
					 else
						 JOptionPane.showMessageDialog(null," 您的竞标价必须低于现有最低竞标价","提示",JOptionPane.INFORMATION_MESSAGE);
				 }
				 repaint();
			}
		});
	  table3.addMouseListener(new MouseAdapter()
		{
			public void mousePressed(MouseEvent e)
			{
				 if   (e.getClickCount()>= 2)   { 
					row3   =   table3.rowAtPoint(e.getPoint());  
				 }
				 repaint();
			}
		});
	  JPanel p1_2=new JPanel();
	  btFresh=new JButton("刷新项目");
	  btFresh.addActionListener(this);
	  p1_2.add(btFresh);
	  p1.add(p1_2,BorderLayout.SOUTH);
	  p1.setBorder(BorderFactory.createTitledBorder("竞标区:"));
	  this.add(p1);
	  JPanel p2=new JPanel(new BorderLayout());
	  JScrollPane jsp2=new JScrollPane(table2);
	  p2.add(jsp2);
	  JPanel p2_2=new JPanel();
	  btFresh2=new JButton("刷新");
	  btFresh2.addActionListener(this);
	  p2_2.add(btFresh2);
	  p2.add(p2_2,BorderLayout.SOUTH);
	  p2.setBorder(BorderFactory.createTitledBorder("当前竞标项目:"));
	  this.add(p2);
	  JPanel p3=new JPanel(new BorderLayout());
	  JScrollPane jsp3=new JScrollPane(table3);
	  p3.add(jsp3);
	  JPanel p3_2=new JPanel();
	  btFinish=new JButton("完成");
	  btFresh3=new JButton("刷新");
	  btFinish.addActionListener(this);
	  btFresh3.addActionListener(this);
	  p3_2.add(btFinish);
	  p3_2.add(btFresh3);
	  p3.add(p3_2,BorderLayout.SOUTH);
	  p3.setBorder(BorderFactory.createTitledBorder("得标项目:"));
	  this.add(p3);
   
  }
  void removeSelete(int index)
	{
		for(int i=index;i<iNum3;i++)
		{
			c[i][0]=c[i+1][0];
			c[i][1]=c[i+1][1];
			c[i][2]=c[i+1][2];
		}
	}

public void actionPerformed(ActionEvent e) {
	if(e.getSource()==btFresh)
	{
		while(iNum1>=0)
		{
			a[iNum1][0]=" ";
			a[iNum1][1]=" ";
			a[iNum1][2]=" ";
			iNum1--;
		}
		byte [] data=new byte[1024];
		try {
			dos.writeInt(9);
			dis.read(data);
			boolean isTrue=false;
			iNum1=0;
			while(true)
			{
				isTrue=dis.readBoolean();
				dos.write("ok".getBytes());
				if(isTrue)
				{
					int num1;
					num1=dis.read(data);
					dos.write("ok".getBytes());
					a[iNum1][1]=new String(data,0,num1,"GB2312");	//strCorpName
					num1=dis.read(data);
					dos.write("ok".getBytes());
					a[iNum1][0]=new String(data,0,num1,"GB2312");
					a[iNum1][2]=dis.readLong();
					dos.write("ok".getBytes());
					
					iNum1++;
				}
				else
				{
					break;
				}
				
	         }
			repaint();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		
	}
	if(e.getSource()==btFresh2)
	{
		while(iNum2>=0)
		{
			b[iNum2][0]=" ";
			b[iNum2][1]=" ";
			b[iNum2][2]=" ";
			iNum2--;
		}
		byte [] data=new byte[1024];
		try {
			dos.writeInt(10);
			dis.read(data);
			dos.write(strMeg.getID().getBytes("GB2312"));
			boolean isTrue=false;
			iNum2=0;
			while(true)
			{
				isTrue=dis.readBoolean();
				dos.write("ok".getBytes());
				if(isTrue)
				{
					int num1;
					num1=dis.read(data);
					dos.write("ok".getBytes());
					b[iNum2][0]=new String(data,0,num1,"GB2312");	
					num1=dis.read(data);
					dos.write("ok".getBytes());
					b[iNum2][1]=new String(data,0,num1,"GB2312");
					b[iNum2][2]=dis.readLong();
					dos.write("ok".getBytes());
					
					iNum2++;
				}
				else
				{
					break;
				}
				
	         }
			repaint();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		
	}
	if(e.getSource()==btFresh3)
	{
		while(iNum3>=0)
		{
			c[iNum3][0]=" ";
			c[iNum3][1]=" ";
			c[iNum3][2]=" ";
			iNum3--;
		}
		byte [] data=new byte[1024];
		try {
			dos.writeInt(11);
			dis.read(data);
			dos.write(strMeg.getID().getBytes("GB2312"));
			boolean isTrue=false;
			iNum3=0;
			while(true)
			{
				isTrue=dis.readBoolean();
				dos.write("ok".getBytes());
				if(isTrue)
				{
					int num1;
					num1=dis.read(data);
					dos.write("ok".getBytes());
					c[iNum3][0]=new String(data,0,num1,"GB2312");	//strCorpName
					num1=dis.read(data);
					dos.write("ok".getBytes());
					c[iNum3][1]=new String(data,0,num1,"GB2312");
					c[iNum3][2]=dis.readLong();
					dos.write("ok".getBytes());
					
					iNum3++;
				}
				else
				{
					break;
				}
				
	         }
			repaint();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
	if(e.getSource()==btFinish)
	{
		byte [] data=new byte[1024];
		try {
			dos.writeInt(13);
			dis.read(data);
			dos.write((strMeg.getID()+"/"+c[row3][0]).getBytes("GB2312"));
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		this.removeSelete(row3);
	}
}
}     
    
    
    
    
    
    
    

⌨️ 快捷键说明

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