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

📄 clientframe.java

📁 自己编写的服务器端jboss向client端发送message的程序
💻 JAVA
字号:
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MalformedObjectNameException;
import javax.management.ReflectionException;
import javax.swing.JButton;
import javax.swing.JFrame;


public class ClientFrame extends JFrame {
	
	private static final long serialVersionUID = 1L;
	private TextField tfInput;
	private TextArea taOutput;
	private JButton btnConfirm;
	private Client client;
	
	public ClientFrame() {
		super("Message_Transaction Client");
		init();
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setBounds(400, 400, 400, 400);
		setVisible(true);
	}
	
	public void setClient (Client client){
		this.client = client;
	}
	
	public void setOutput(String msg){
		System.out.println(msg);
		taOutput.setText(taOutput.getText()+"\n"+msg);
	}
	
	private void init() {
		setLayout(null);
		tfInput = new TextField(50);
		add(tfInput);
		tfInput.setBounds(40, 40, 300, 40);
		
		taOutput = new TextArea(50, 50);
		add(taOutput);
		taOutput.setBounds(40, 140, 300, 200);
		taOutput.setEditable(false);
		
		btnConfirm = new JButton("Confirm");
		add(btnConfirm);
		btnConfirm.setBounds(250, 90, 90, 30);
		
		btnConfirm.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String[] args = tfInput.getText().split(" ");
				try {
					client.doTransaction(args[0], args[1], Float.parseFloat(args[2]));
				} catch (MalformedObjectNameException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (InstanceNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (NumberFormatException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (NullPointerException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (MBeanException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ReflectionException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		
	}

	public static void main(String[] args) {
		ClientFrame cf = new ClientFrame();
		Client client = new Client("127.0.0.1:1099");
		cf.setClient(client);
		client.setClientFrame(cf);
	}
	
	

}

⌨️ 快捷键说明

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