`
hoonee
  • 浏览: 9822 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Demo

 
阅读更多
package com.huawei.crs.dataswitch.ui;



import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.Border;

public class DataSwitchUI
{
	public static void main(String[] args)
	{

    	//获取屏幕尺寸
    	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    	
    	try
		{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException e1)
		{
			e1.printStackTrace();
		} catch (InstantiationException e1)
		{
			e1.printStackTrace();
		} catch (IllegalAccessException e1)
		{
			e1.printStackTrace();
		} catch (UnsupportedLookAndFeelException e1)
		{
			e1.printStackTrace();
		}
		
    	final JFrame jFrame = new JFrame("数据切换SQL脚本生成工具");
		Image image = null;
		
		try
		{
			image = ImageIO.read(new FileInputStream("img/logo.jpg"));
		} 
		catch (FileNotFoundException e)
		{
			JOptionPane.showMessageDialog(jFrame,"图片Logo没有找到 !","警告信息",JOptionPane.WARNING_MESSAGE);
			//System.exit(0);
		} 
		catch (IOException e)
		{
			JOptionPane.showMessageDialog(jFrame,"读取文件异常 !","警告信息",JOptionPane.WARNING_MESSAGE);
			//System.exit(0);
		}  

        jFrame.setIconImage(image);
    	Container container = jFrame.getContentPane();
    	container.setLayout(null);

		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 10, 770, 180);
		scrollPane.setWheelScrollingEnabled(true);
		scrollPane.setBorder(BorderFactory.createTitledBorder("信息栏"));
		container.add(scrollPane);
    	
    	
		final JTextArea resultTextArea = new JTextArea();
		
		Color color = new Color( 255, 255, 255);
		Color selectedColor = new Color( 0, 255, 0);
		
		Border border = BorderFactory.createLineBorder(Color.black);
		//border = BorderFactory.createLoweredBevelBorder();
		//border = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
		//border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
		//border = BorderFactory.createRaisedBevelBorder();
		
		resultTextArea.setBorder(border);
		resultTextArea.setBackground(color);
		resultTextArea.setSelectedTextColor(selectedColor);
		resultTextArea.setText(
				"\n\t数据切换SQL脚本生成工具说明: " +
				"\n\t\t\t 待补充");
		
		resultTextArea.setEditable(false);
		scrollPane.setViewportView(resultTextArea);
		
		
		JPanel comparePane = new JPanel();
		comparePane.setLayout(null);
		comparePane.setBounds(10, 200, 770, 120);
		comparePane.setBorder(BorderFactory.createTitledBorder("生成SQL脚本文件"));
		container.add(comparePane);
		
		
		JLabel expectLabel = new JLabel("模  块:");
		expectLabel.setBounds(60, 40, 80, 26);
		comparePane.add(expectLabel);
		
		final JTextField expectTextField = new JTextField();
		expectTextField.setBounds(120, 40, 220, 26);
		comparePane.add(expectTextField);

		
		expectTextField.addKeyListener(new KeyAdapter(){

			@Override
			public void keyReleased(KeyEvent e) {
				StringBuffer sb = new StringBuffer();
				String content = expectTextField.getText();
				System.out.println(content);
				
				int len = 5;

				for(int i = 0; len * i <= content.length(); i++)
				{
					sb.append(content.substring(i, len * i));
					sb.append("\n");
				}
				
				System.out.println(sb.toString());
				
//				resultTextArea.setText(sb.toString());
			}
		});
		
		
		JLabel actualLabel = new JLabel("文  件:");
		actualLabel.setBounds(390, 40, 80, 26);
		comparePane.add(actualLabel);
		
		final JTextField actualTextField = new JTextField();
		actualTextField.setBounds(450, 40, 200, 26);
		comparePane.add(actualTextField);
		
    	
		JButton actualButton = new JButton("...");
		actualButton.setBounds(650, 40, 20, 26);
		comparePane.add(actualButton);
		actualButton.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				JFileChooser jFileChooser = new JFileChooser();
				 int returnVal = jFileChooser.showSaveDialog(jFrame); 
	             if (returnVal == JFileChooser.APPROVE_OPTION) 
	             { 
	                 File file = jFileChooser.getSelectedFile();               
	                 actualTextField.setText(file.getAbsolutePath());
	             }
			}
		});
		
		JButton compareButton = new JButton("生成脚本");
		compareButton.setBounds(590, 80, 80, 26);
		comparePane.add(compareButton);
		compareButton.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				String expaceFile = expectTextField.getText();
				String actualFile = actualTextField.getText();
				if(null == expaceFile || "".equals(expaceFile))
				{
					JOptionPane.showMessageDialog(jFrame,"预期文件不能为空!","警告信息",JOptionPane.WARNING_MESSAGE);
				}
				else if(null == actualFile || "".equals(actualFile))
				{
					JOptionPane.showMessageDialog(jFrame,"实际文件不能为空!","警告信息",JOptionPane.WARNING_MESSAGE);
				}
				else
				{
					
				}
			}
		});
		
		
		JPanel sortPane = new JPanel();
		sortPane.setLayout(null);
		sortPane.setBounds(10, 330, 770, 120);
		sortPane.setBorder(BorderFactory.createTitledBorder("执行SQL脚本文件"));
		container.add(sortPane);
    	
		JLabel inputLabel = new JLabel("文  件:");
		inputLabel.setBounds(60, 40, 80, 26);
		sortPane.add(inputLabel);
		
		final JTextField inputTextField = new JTextField();
		inputTextField.setBounds(120, 40, 200, 26);
		sortPane.add(inputTextField);
		
		JButton inputButton = new JButton("...");
		inputButton.setBounds(320, 40, 20, 26);
		sortPane.add(inputButton);
		inputButton.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				JFileChooser jFileChooser = new JFileChooser();
				 int returnVal = jFileChooser.showOpenDialog(jFrame); 
	             if (returnVal == JFileChooser.APPROVE_OPTION) 
	             { 
	                 File file = jFileChooser.getSelectedFile();               
	                 inputTextField.setText(file.getAbsolutePath());
	             }
			}
		});
    	
		
		
		
		
		JButton sortButton = new JButton("执行脚本");
		sortButton.setBounds(388, 40, 80, 26);//590, 80, 80, 26
		sortPane.add(sortButton);
		sortButton.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				String inputFile = inputTextField.getText();
				String outputFile = inputTextField.getText();
				String sequenceFlag = "";
				if(null == inputFile || "".equals(inputFile))
				{
					JOptionPane.showMessageDialog(jFrame,"输入文件不能为空!","警告信息",JOptionPane.WARNING_MESSAGE);
				}
				else if(null == outputFile || "".equals(outputFile))
				{
					JOptionPane.showMessageDialog(jFrame,"输出文件不能为空!","警告信息",JOptionPane.WARNING_MESSAGE);
				}
				else
				{
                   
				}
			}
		});
		
    	int width = 800;
    	int height = (int)(width * 0.618);
		jFrame.setSize(width,height);
		int x = (dimension.width - jFrame.getSize().width)/2;
		int y = (dimension.height - jFrame.getSize().height)/2;
		jFrame.setLocation(x, y);
		jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		jFrame.setResizable(false);
		jFrame.setVisible(true);
	}
}

 

分享到:
评论

相关推荐

    小程序源码 移动端小商城DEMO (商城demo源码) (代码源)

    小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) ...

    微信小程序学习demo:基础接口演示demo(源代码+截图)

    微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信...

    转盘抽奖demo 转盘抽奖demo

    转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖...

    微信小程序 小程序官方Demo (源码)

    微信小程序 小程序官方Demo (源码)微信小程序 小程序官方Demo (源码)微信小程序 小程序官方Demo (源码)微信小程序 小程序官方Demo (源码)微信小程序 小程序官方Demo (源码)微信小程序 小程序官方Demo (源码)微信小...

    一些html页面或是效果的demo

    一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果...

    微信小程序demo:商城(源代码+截图)

    微信小程序demo:商城(源代码+截图)微信小程序demo:商城(源代码+截图)微信小程序demo:商城(源代码+截图)微信小程序demo:商城(源代码+截图)微信小程序demo:商城(源代码+截图)微信小程序demo:商城(源代码+截图)...

    demo_微服务demo

    演示demo 微服务练习demo

    minio分片上传Demo.zip

    minio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片上传Demo.zipminio分片...

    Android TCP Socket通信实例Demo源码Apk下载

    最近有个项目模块需要用到TCP Socket通讯,遇到了一个大坑,所以做了这个Demo。 本Demo主要实现了安卓(Android)TCP 客户端(Client)和服务器(Server)Demo的Socket通讯。以及对接硬件的项目数据在十六进制&&byte&&int...

    微信小程序服务端开发demo(源代码+截图)

    微信小程序服务端开发demo(源代码+截图)微信小程序服务端开发demo(源代码+截图)微信小程序服务端开发demo(源代码+截图)微信小程序服务端开发demo(源代码+截图)微信小程序服务端开发demo(源代码+截图)微信小程序...

    android 串口测试demo 代码简单 无bug 完美运行

    android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo...

    通联支付官方demo_DEMO_通联支付DEMO_通联支付官方demo_

    通联支付官方demo

    STM32开发工具 DfuSe_Demo_V3.0

    STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V3.0STM32开发工具 DfuSe_Demo_V...

    echarts 图表案例demo很多好看的demo

    echarts 图表案例demo很多好看的demoecharts 图表案例demo很多好看的demoecharts 图表案例demo很多好看的demoecharts 图表案例demo很多好看的demoecharts 图表案例demo很多好看的demoecharts 图表案例demo很多好看的...

    PHP支付小Demo(含支付宝、微信支付、银联支付).zip

    PHP支付小Demo(含支付宝、微信支付、银联支付PHP支付小Demo(含支付宝、微信支付、银联支付PHP支付小Demo(含支付宝、微信支付、银联支付PHP支付小Demo(含支付宝、微信支付、银联支付PHP支付小Demo(含支付宝、微信支付...

    VC代码 CButtonST_demo (实用代码源)

    VC代码 CButtonST_demo (实用代码源)VC代码 CButtonST_demo (实用代码源)VC代码 CButtonST_demo (实用代码源)VC代码 CButtonST_demo (实用代码源)VC代码 CButtonST_demo (实用代码源)VC代码 CButtonST_demo (实用...

    微信小程序经典demo学习案例:学习用demo(源代码+截图)

    微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+...

    clientDEMO clientdemo调试软件

    clientDEMO,监控必备软件,监控调试助手,网络必备 clientDEMO,监控必备软件,监控调试助手,网络必备

    微信小程序练习demo:练习demo(源代码+截图)

    微信小程序练习demo:练习demo(源代码+截图)微信小程序练习demo:练习demo(源代码+截图)微信小程序练习demo:练习demo(源代码+截图)微信小程序练习demo:练习demo(源代码+截图)微信小程序练习demo:练习demo(源代码+...

    模拟binder通信的demo

    模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo模拟binder通信的demo...

Global site tag (gtag.js) - Google Analytics