WSDL报文编号—文本框

package com.company;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class GUI 
{
	private JFrame jFrame = null;
	private JButton confirmButton = null;
	private JTextArea jta = null;
	private JScrollPane jsp = null;
	private ButtonListener buttLis = new ButtonListener();
	
	public void Frame() {
		jFrame = new JFrame("报 文 编 号");
		jFrame.setLayout(new FlowLayout());
		jta = new JTextArea(40,40);
		jsp = new JScrollPane(jta);
		confirmButton = new JButton();
		
		//添加控件
		jFrame.add(jsp);
		jFrame.add(confirmButton);
		confirmButton.setText("编号");
		confirmButton.addActionListener(buttLis);
		
		//设置
		jFrame.setBounds(100, 100, 800, 800);//frame初始显示位置
		jFrame.setSize(500,800);
		jFrame.setVisible(true);
		jFrame.setResizable(false);//将frame设置成不能改变大小
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	/**
	 * main	函数
	 */
	public static void main(String[] args) 
	{
		GUI gui = new GUI();
		gui.Frame();
	}

	/**
	 * 监听类
	 */
	class ButtonListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent event) 
		{
			// TODO Auto-generated method stub
			if (event.getSource().equals(confirmButton)) 
			{
				Convert2Number con = new Convert2Number();
				//从文本框得到文本
				String resStr = jta.getText();
				jta.setText(con.convert(resStr));
			}
		}

	}
}


==
package com.company;

public class Convert2Number 
{
	public String convert(String str)
	{
		int i = 1;
		int j = str.indexOf("?");
		while(-1 != j)
		{
			str = str.replaceFirst("[?]", String.valueOf(i));
			i ++;
			j = str.indexOf("?");
		}
		return str;
	}
	public static void main(String[] args) 
	{
		Convert2Number con = new Convert2Number();
		con.convert("abc?abc?abc?");
	}
}

你可能感兴趣的:(wsdl)