删除 src/main/java/com/bonus/autoweb/UI/frame/LogAction.java
This commit is contained in:
parent
cebf387cc6
commit
bd73da6007
|
|
@ -1,734 +0,0 @@
|
|||
package com.bonus.autoweb.UI.frame;
|
||||
|
||||
import com.bonus.autoweb.UI.entity.LogBean;
|
||||
import com.bonus.autoweb.base.DataConfig;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志页面
|
||||
*
|
||||
* @author zys
|
||||
*/
|
||||
public class LogAction extends JFrame implements MouseListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
JPanel jp;
|
||||
|
||||
JTextField weatherJt, lowTemperatureJt, temperatureJt, eventDetectionTitleJt, powerWorkTitleJt, resourceCheckTitleJt,
|
||||
communicationsTestTitleJt, dailyOperationTitleJt, dailySubmissionTitleJt, warningDisposalTitleJt, generalChroniclesTitleJt;
|
||||
JTextArea eventDetectionContentJt,powerWorkContentJt,resourceCheckContentJt,communicationsTestContentJt,
|
||||
dailyOperationContentJt,dailySubmissionContentJt,warningDisposalContentJt,generalChroniclesContentJt;
|
||||
|
||||
JButton btn;
|
||||
|
||||
JScrollPane jScroller;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new LogAction();
|
||||
}
|
||||
|
||||
public LogAction() {
|
||||
//设置显示窗口标题
|
||||
setTitle("日志填报");
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
//设置窗口显示尺寸
|
||||
setSize((dimension.width + 420) / 2, dimension.height);
|
||||
Point p = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
|
||||
setBounds(p.x - (dimension.width + 180) / 3 * 2 / 2, p.y - dimension.height / 2 + 25,
|
||||
(dimension.width + 420) / 3 * 2, dimension.height - 50);
|
||||
setResizable(false);
|
||||
//设置窗口是否可以关闭
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
//获取本窗口的内容窗格
|
||||
Container c = getContentPane();
|
||||
JPanel jPanel = initMainJpanel();
|
||||
jScroller = new JScrollPane(jPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
//设置滚轮速度
|
||||
jScroller.getVerticalScrollBar().setUnitIncrement(20);
|
||||
c.add(jScroller);
|
||||
//设置本窗口是否可见
|
||||
setVisible(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
|
||||
// 反序列化--> 解决乱码问题
|
||||
File file = new File(DataConfig.filePath + "\\log.xml");
|
||||
InputStreamReader in = null;
|
||||
String xml = null;
|
||||
try {
|
||||
//主要就是这里的设置
|
||||
in = new InputStreamReader(new FileInputStream(file), Charset.forName("gbk") );
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char[] array= new char[1024];
|
||||
int length = -1;
|
||||
while((length=in.read(array))!= -1){
|
||||
sb.append(array, 0, length);
|
||||
}
|
||||
in.close();
|
||||
xml=sb.toString().trim();
|
||||
System.out.println(xml);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
xstream.alias("log", LogBean.class);
|
||||
LogBean bean = (LogBean) xstream.fromXML(xml);
|
||||
weatherJt.setText(bean.getWeather());
|
||||
lowTemperatureJt.setText(bean.getMin_temperature());
|
||||
temperatureJt.setText(bean.getMax_temperature());
|
||||
eventDetectionTitleJt.setText(bean.getEvent_detection_title());
|
||||
eventDetectionContentJt.setText(bean.getEvent_detection_content());
|
||||
powerWorkTitleJt.setText(bean.getPower_work_title());
|
||||
powerWorkContentJt.setText(bean.getPower_work_content());
|
||||
resourceCheckTitleJt.setText(bean.getResource_check_title());
|
||||
resourceCheckContentJt.setText(bean.getResource_check_content());
|
||||
communicationsTestTitleJt.setText(bean.getCommunications_test_title());
|
||||
communicationsTestContentJt.setText(bean.getCommunications_test_content());
|
||||
dailyOperationTitleJt.setText(bean.getDaily_operation_title());
|
||||
dailyOperationContentJt.setText(bean.getDaily_operation_content());
|
||||
dailySubmissionTitleJt.setText(bean.getDaily_submission_title());
|
||||
dailySubmissionContentJt.setText(bean.getDaily_submission_content());
|
||||
warningDisposalTitleJt.setText(bean.getWarning_disposal_title());
|
||||
warningDisposalContentJt.setText(bean.getWarning_disposal_content());
|
||||
generalChroniclesTitleJt.setText(bean.getGeneral_chronicles_title());
|
||||
generalChroniclesContentJt.setText(bean.getGeneral_chronicles_content());
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel initMainJpanel() {
|
||||
int height = 120 * 40 + 35;
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
jp = new JPanel();
|
||||
jp.setOpaque(false);
|
||||
jp.setLayout(null);
|
||||
jp.setSize(dimension);
|
||||
jp.setPreferredSize(new Dimension((dimension.width + 100) / 2, height));
|
||||
int oneLabelY = 20;
|
||||
int oneTextY = 35;
|
||||
/**
|
||||
* 天气
|
||||
*/
|
||||
JLabel weatherLabel = new JLabel("天气");
|
||||
weatherLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
weatherLabel.setForeground(new Color(11, 24, 76));
|
||||
int weatherJlx = 30;
|
||||
weatherLabel.setBounds(weatherJlx, oneLabelY, 400, 100);
|
||||
/**
|
||||
* 天气输入框
|
||||
*/
|
||||
weatherJt = new JTextField();
|
||||
setTextFiledColor(weatherJt);
|
||||
int weatherJtX = weatherJlx + 150;
|
||||
weatherJt.setBounds(weatherJtX, oneTextY, 250, 80);
|
||||
|
||||
/**添加最低气温 调整整体宽度位置*/
|
||||
/**
|
||||
* 最低气温
|
||||
*/
|
||||
JLabel lowTemperatureLabel = new JLabel("最低气温");
|
||||
lowTemperatureLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
lowTemperatureLabel.setForeground(new Color(11, 24, 76));
|
||||
int lowTemperatureJlx = weatherJtX + 270;
|
||||
lowTemperatureLabel.setBounds(lowTemperatureJlx, oneLabelY, 200, 100);
|
||||
/**
|
||||
* 最低气温输入框
|
||||
*/
|
||||
lowTemperatureJt = new JTextField();
|
||||
setTextFiledColor(lowTemperatureJt);
|
||||
int lowTemperatureJtX = lowTemperatureJlx + 220;
|
||||
lowTemperatureJt.setBounds(lowTemperatureJtX, oneTextY, 160, 80);
|
||||
|
||||
|
||||
/**
|
||||
* 最高气温
|
||||
*/
|
||||
JLabel temperatureLabel = new JLabel("最高气温");
|
||||
temperatureLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
temperatureLabel.setForeground(new Color(11, 24, 76));
|
||||
int temperatureJlx = weatherJtX + 700;
|
||||
temperatureLabel.setBounds(temperatureJlx, oneLabelY, 200, 100);
|
||||
/**
|
||||
* 最高气温输入框
|
||||
*/
|
||||
temperatureJt = new JTextField();
|
||||
setTextFiledColor(temperatureJt);
|
||||
int temperatureJtX = temperatureJlx + 220;
|
||||
temperatureJt.setBounds(temperatureJtX, oneTextY, 160, 80);
|
||||
|
||||
/**
|
||||
* 一、事件检测
|
||||
*/
|
||||
JLabel eventDetectionLabel = new JLabel("一、事件检测");
|
||||
eventDetectionLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
eventDetectionLabel.setForeground(new Color(11, 24, 76));
|
||||
int eventDetectionJlx = 30;
|
||||
int eventDetectionJly = oneLabelY + 120;
|
||||
eventDetectionLabel.setBounds(eventDetectionJlx, eventDetectionJly, 500, 100);
|
||||
/**
|
||||
* 事件检测标题输入框
|
||||
*/
|
||||
eventDetectionTitleJt = new JTextField();
|
||||
setTextFiledColor(eventDetectionTitleJt);
|
||||
int eventDetectionTitleJtX = eventDetectionJlx + 500;
|
||||
eventDetectionTitleJt.setBounds(eventDetectionTitleJtX, eventDetectionJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(eventDetectionTitleJt.getText())) {
|
||||
eventDetectionTitleJt.addFocusListener(new MyFocusListener("请输入事件检测标题", eventDetectionTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件检测内容输入框
|
||||
*/
|
||||
// eventDetectionContentJt = new JTextField();
|
||||
// setTextFiledColor(eventDetectionContentJt);
|
||||
// int eventDetectionContentJtY = eventDetectionJly + 120;
|
||||
// eventDetectionContentJt.setBounds(eventDetectionJlx, eventDetectionContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(eventDetectionContentJt.getText())) {
|
||||
// eventDetectionContentJt.addFocusListener(new MyFocusListener("请输入事件检测内容", eventDetectionContentJt));
|
||||
// }
|
||||
eventDetectionContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder0 = new Placeholder(eventDetectionContentJt, "请输入事件检测内容...");
|
||||
eventDetectionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
eventDetectionContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
eventDetectionContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
eventDetectionContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane jsp=new JScrollPane(eventDetectionContentJt); //将文本域放入滚动窗口
|
||||
Dimension size=eventDetectionContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int eventDetectionContentJtY = eventDetectionJly + 120;
|
||||
jsp.setBounds(eventDetectionJlx,eventDetectionContentJtY,1310,size.height+20);
|
||||
|
||||
jp.add(jsp);
|
||||
|
||||
/**
|
||||
* 二、保电工作
|
||||
*/
|
||||
JLabel powerWorkLabel = new JLabel("二、保电工作");
|
||||
powerWorkLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
powerWorkLabel.setForeground(new Color(11, 24, 76));
|
||||
int powerWorkJlx = 30;
|
||||
int powerWorkJly = size.height + 300;
|
||||
powerWorkLabel.setBounds(powerWorkJlx, powerWorkJly, 500, 100);
|
||||
/**
|
||||
* 保电工作标题输入框
|
||||
*/
|
||||
powerWorkTitleJt = new JTextField();
|
||||
setTextFiledColor(powerWorkTitleJt);
|
||||
int powerWorkTitleJtX = powerWorkJlx + 500;
|
||||
powerWorkTitleJt.setBounds(powerWorkTitleJtX, powerWorkJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(powerWorkTitleJt.getText())) {
|
||||
powerWorkTitleJt.addFocusListener(new MyFocusListener("请输入保电工作标题", powerWorkTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保电工作内容输入框
|
||||
*/
|
||||
// powerWorkContentJt = new JTextField();
|
||||
// setTextFiledColor(powerWorkContentJt);
|
||||
//
|
||||
// powerWorkContentJt.setBounds(powerWorkJlx, powerWorkContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(powerWorkContentJt.getText())) {
|
||||
// powerWorkContentJt.addFocusListener(new MyFocusListener("请输入保电工作内容", powerWorkContentJt));
|
||||
// }
|
||||
powerWorkContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder1 = new Placeholder(powerWorkContentJt, "请输入保电工作内容...");
|
||||
powerWorkContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
powerWorkContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
powerWorkContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
powerWorkContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane powerWorkContentJtJsp=new JScrollPane(powerWorkContentJt); //将文本域放入滚动窗口
|
||||
Dimension powerWorkContentJtSize=powerWorkContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int powerWorkContentJtY = powerWorkJly + 120;
|
||||
powerWorkContentJtJsp.setBounds(eventDetectionJlx,powerWorkContentJtY,1310,powerWorkContentJtSize.height+20);
|
||||
|
||||
jp.add(powerWorkContentJtJsp);
|
||||
/**
|
||||
* 三、资源核查情况
|
||||
*/
|
||||
JLabel resourceCheckLabel = new JLabel("三、资源核查情况");
|
||||
resourceCheckLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
resourceCheckLabel.setForeground(new Color(11, 24, 76));
|
||||
int resourceCheckJlx = 30;
|
||||
int resourceCheckJly = powerWorkContentJtY + 450;
|
||||
resourceCheckLabel.setBounds(resourceCheckJlx, resourceCheckJly, 500, 100);
|
||||
/**
|
||||
* 资源核查情况标题输入框
|
||||
*/
|
||||
resourceCheckTitleJt = new JTextField();
|
||||
setTextFiledColor(resourceCheckTitleJt);
|
||||
int resourceCheckTitleJtX = resourceCheckJlx + 500;
|
||||
resourceCheckTitleJt.setBounds(resourceCheckTitleJtX, resourceCheckJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(resourceCheckTitleJt.getText())) {
|
||||
resourceCheckTitleJt.addFocusListener(new MyFocusListener("请输入资源核查情况标题", resourceCheckTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源核查情况内容输入框
|
||||
*/
|
||||
// resourceCheckContentJt = new JTextField();
|
||||
// setTextFiledColor(resourceCheckContentJt);
|
||||
// int resourceCheckContentJtY = resourceCheckJly + 120;
|
||||
// resourceCheckContentJt.setBounds(resourceCheckJlx, resourceCheckContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(resourceCheckContentJt.getText())) {
|
||||
// resourceCheckContentJt.addFocusListener(new MyFocusListener("请输入资源核查情况内容", resourceCheckContentJt));
|
||||
// }
|
||||
resourceCheckContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder2 = new Placeholder(resourceCheckContentJt, "请输入资源核查情况内容...");
|
||||
resourceCheckContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
resourceCheckContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
resourceCheckContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
resourceCheckContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane resourceCheckContentJtJsp=new JScrollPane(resourceCheckContentJt); //将文本域放入滚动窗口
|
||||
Dimension resourceCheckContentJtSize=resourceCheckContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int resourceCheckContentJtY = resourceCheckJly + 120;
|
||||
resourceCheckContentJtJsp.setBounds(eventDetectionJlx,resourceCheckContentJtY,1310,resourceCheckContentJtSize.height+20);
|
||||
jp.add(resourceCheckContentJtJsp);
|
||||
/**
|
||||
* 四、通信测试情况
|
||||
*/
|
||||
JLabel communicationsTestLabel = new JLabel("四、通信测试情况");
|
||||
communicationsTestLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
communicationsTestLabel.setForeground(new Color(11, 24, 76));
|
||||
int communicationsTestJlx = 30;
|
||||
int communicationsTestJly = resourceCheckContentJtY + 450;
|
||||
communicationsTestLabel.setBounds(communicationsTestJlx, communicationsTestJly, 500, 100);
|
||||
/**
|
||||
* 通信测试情况标题输入框
|
||||
*/
|
||||
communicationsTestTitleJt = new JTextField();
|
||||
setTextFiledColor(communicationsTestTitleJt);
|
||||
int communicationsTestTitleJtX = communicationsTestJlx + 500;
|
||||
communicationsTestTitleJt.setBounds(communicationsTestTitleJtX, communicationsTestJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(communicationsTestTitleJt.getText())) {
|
||||
communicationsTestTitleJt.addFocusListener(new MyFocusListener("请输入通信测试情况标题", communicationsTestTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通信测试情况内容输入框
|
||||
*/
|
||||
// communicationsTestContentJt = new JTextField();
|
||||
// setTextFiledColor(communicationsTestContentJt);
|
||||
// int communicationsTestContentJtY = communicationsTestJly + 120;
|
||||
// communicationsTestContentJt.setBounds(communicationsTestJlx, communicationsTestContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(communicationsTestContentJt.getText())) {
|
||||
// communicationsTestContentJt.addFocusListener(new MyFocusListener("请输入通信测试情况内容", communicationsTestContentJt));
|
||||
// }
|
||||
|
||||
communicationsTestContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder3 = new Placeholder(communicationsTestContentJt, "请输入通信测试情况内容...");
|
||||
communicationsTestContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
communicationsTestContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
communicationsTestContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
communicationsTestContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane communicationsTestContentJtJsp=new JScrollPane(communicationsTestContentJt); //将文本域放入滚动窗口
|
||||
Dimension communicationsTestContentJtSize=communicationsTestContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int communicationsTestContentJtY = communicationsTestJly + 120;
|
||||
communicationsTestContentJtJsp.setBounds(eventDetectionJlx,communicationsTestContentJtY,1310,communicationsTestContentJtSize.height+20);
|
||||
jp.add(communicationsTestContentJtJsp);
|
||||
|
||||
/**
|
||||
* 五、日常操作情况
|
||||
*/
|
||||
JLabel dailyOperationLabel = new JLabel("五、日常操作情况");
|
||||
dailyOperationLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
dailyOperationLabel.setForeground(new Color(11, 24, 76));
|
||||
int dailyOperationJlx = 30;
|
||||
int dailyOperationJly = communicationsTestContentJtY + 450;
|
||||
dailyOperationLabel.setBounds(dailyOperationJlx, dailyOperationJly, 500, 100);
|
||||
/**
|
||||
* 日常操作情况标题输入框
|
||||
*/
|
||||
dailyOperationTitleJt = new JTextField();
|
||||
setTextFiledColor(dailyOperationTitleJt);
|
||||
int dailyOperationTitleJtX = dailyOperationJlx + 500;
|
||||
dailyOperationTitleJt.setBounds(dailyOperationTitleJtX, dailyOperationJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(dailyOperationTitleJt.getText())) {
|
||||
dailyOperationTitleJt.addFocusListener(new MyFocusListener("请输入日常操作情况标题", dailyOperationTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 日常操作情况内容输入框
|
||||
*/
|
||||
// dailyOperationContentJt = new JTextField();
|
||||
// setTextFiledColor(dailyOperationContentJt);
|
||||
// int dailyOperationContentJtY = dailyOperationJly + 120;
|
||||
// dailyOperationContentJt.setBounds(dailyOperationJlx, dailyOperationContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(dailyOperationContentJt.getText())) {
|
||||
// dailyOperationContentJt.addFocusListener(new MyFocusListener("请输入日常操作情况内容", dailyOperationContentJt));
|
||||
// }
|
||||
|
||||
dailyOperationContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder4 = new Placeholder(dailyOperationContentJt, "请输入日常操作情况内容...");
|
||||
dailyOperationContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
dailyOperationContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
dailyOperationContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
dailyOperationContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane dailyOperationContentJtJsp=new JScrollPane(dailyOperationContentJt); //将文本域放入滚动窗口
|
||||
Dimension dailyOperationContentJtSize=dailyOperationContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int dailyOperationContentJtY = dailyOperationJly + 120;
|
||||
dailyOperationContentJtJsp.setBounds(eventDetectionJlx,dailyOperationContentJtY,1310,dailyOperationContentJtSize.height+20);
|
||||
jp.add(dailyOperationContentJtJsp);
|
||||
|
||||
/**
|
||||
* 六、日报提报情况
|
||||
*/
|
||||
JLabel dailySubmissionLabel = new JLabel("六、日报提报情况");
|
||||
dailySubmissionLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
dailySubmissionLabel.setForeground(new Color(11, 24, 76));
|
||||
int dailySubmissionJlx = 30;
|
||||
int dailySubmissionJly = dailyOperationContentJtY + 450;
|
||||
dailySubmissionLabel.setBounds(dailySubmissionJlx, dailySubmissionJly, 500, 100);
|
||||
/**
|
||||
* 日报提报情况标题输入框
|
||||
*/
|
||||
dailySubmissionTitleJt = new JTextField();
|
||||
setTextFiledColor(dailySubmissionTitleJt);
|
||||
int dailySubmissionTitleJtX = dailySubmissionJlx + 500;
|
||||
dailySubmissionTitleJt.setBounds(dailySubmissionTitleJtX, dailySubmissionJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(dailySubmissionTitleJt.getText())) {
|
||||
dailySubmissionTitleJt.addFocusListener(new MyFocusListener("请输入日报提报情况标题", dailySubmissionTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报提报情况内容输入框
|
||||
*/
|
||||
// dailySubmissionContentJt = new JTextField();
|
||||
// setTextFiledColor(dailySubmissionContentJt);
|
||||
// int dailySubmissionContentJtY = dailySubmissionJly + 120;
|
||||
// dailySubmissionContentJt.setBounds(dailySubmissionJlx, dailySubmissionContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(dailySubmissionContentJt.getText())) {
|
||||
// dailySubmissionContentJt.addFocusListener(new MyFocusListener("请输入日报提报情况内容", dailySubmissionContentJt));
|
||||
// }
|
||||
|
||||
dailySubmissionContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder5 = new Placeholder(dailySubmissionContentJt, "请输入日报提报情况内容...");
|
||||
dailySubmissionContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
dailySubmissionContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
dailySubmissionContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
dailySubmissionContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane dailySubmissionContentJtJsp=new JScrollPane(dailySubmissionContentJt); //将文本域放入滚动窗口
|
||||
Dimension dailySubmissionContentJtSize=dailySubmissionContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int dailySubmissionContentJtY = dailySubmissionJly + 120;
|
||||
dailySubmissionContentJtJsp.setBounds(eventDetectionJlx,dailySubmissionContentJtY,1310,dailySubmissionContentJtSize.height+20);
|
||||
jp.add(dailySubmissionContentJtJsp);
|
||||
|
||||
/**
|
||||
* 七、预警处置
|
||||
*/
|
||||
JLabel warningDisposalLabel = new JLabel("七、预警处置");
|
||||
warningDisposalLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
warningDisposalLabel.setForeground(new Color(11, 24, 76));
|
||||
int warningDisposalJlx = 30;
|
||||
int warningDisposalJly = dailySubmissionContentJtY + 450;
|
||||
warningDisposalLabel.setBounds(warningDisposalJlx, warningDisposalJly, 500, 100);
|
||||
/**
|
||||
* 预警处置标题输入框
|
||||
*/
|
||||
warningDisposalTitleJt = new JTextField();
|
||||
setTextFiledColor(warningDisposalTitleJt);
|
||||
int warningDisposalTitleJtX = warningDisposalJlx + 500;
|
||||
warningDisposalTitleJt.setBounds(warningDisposalTitleJtX, warningDisposalJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(warningDisposalTitleJt.getText())) {
|
||||
warningDisposalTitleJt.addFocusListener(new MyFocusListener("请输入预警处置标题", warningDisposalTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预警处置内容输入框
|
||||
*/
|
||||
// warningDisposalContentJt = new JTextField();
|
||||
// setTextFiledColor(warningDisposalContentJt);
|
||||
// int warningDisposalContentJtY = warningDisposalJly + 120;
|
||||
// warningDisposalContentJt.setBounds(warningDisposalJlx, warningDisposalContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(warningDisposalContentJt.getText())) {
|
||||
// warningDisposalContentJt.addFocusListener(new MyFocusListener("请输入预警处置内容", warningDisposalContentJt));
|
||||
// }
|
||||
|
||||
warningDisposalContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder6 = new Placeholder(warningDisposalContentJt, "请输入预警处置内容...");
|
||||
warningDisposalContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
warningDisposalContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
warningDisposalContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
warningDisposalContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane warningDisposalContentJtJsp=new JScrollPane(warningDisposalContentJt); //将文本域放入滚动窗口
|
||||
Dimension warningDisposalContentJtSize=warningDisposalContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int warningDisposalContentJtY = warningDisposalJly + 120;
|
||||
warningDisposalContentJtJsp.setBounds(eventDetectionJlx,warningDisposalContentJtY,1310,warningDisposalContentJtSize.height+20);
|
||||
jp.add(warningDisposalContentJtJsp);
|
||||
|
||||
/**
|
||||
* 八、一般记事
|
||||
*/
|
||||
JLabel generalChroniclesLabel = new JLabel("八、一般记事");
|
||||
generalChroniclesLabel.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
generalChroniclesLabel.setForeground(new Color(11, 24, 76));
|
||||
int generalChroniclesJlx = 30;
|
||||
int generalChroniclesJly = warningDisposalContentJtY + 450;
|
||||
generalChroniclesLabel.setBounds(generalChroniclesJlx, generalChroniclesJly, 500, 100);
|
||||
/**
|
||||
* 一般记事标题输入框
|
||||
*/
|
||||
generalChroniclesTitleJt = new JTextField();
|
||||
setTextFiledColor(generalChroniclesTitleJt);
|
||||
int generalChroniclesTitleJtX = generalChroniclesJlx + 500;
|
||||
generalChroniclesTitleJt.setBounds(generalChroniclesTitleJtX, generalChroniclesJly + 15, 810, 80);
|
||||
if (StringHelper.isEmptyAndNull(generalChroniclesTitleJt.getText())) {
|
||||
generalChroniclesTitleJt.addFocusListener(new MyFocusListener("请输入一般记事标题", generalChroniclesTitleJt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一般记事内容输入框
|
||||
*/
|
||||
// generalChroniclesContentJt = new JTextField();
|
||||
// setTextFiledColor(generalChroniclesContentJt);
|
||||
// int generalChroniclesContentJtY = generalChroniclesJly + 120;
|
||||
// generalChroniclesContentJt.setBounds(generalChroniclesJlx, generalChroniclesContentJtY, 1310, 120);
|
||||
// if (StringHelper.isEmptyAndNull(generalChroniclesContentJt.getText())) {
|
||||
// generalChroniclesContentJt.addFocusListener(new MyFocusListener("请输入一般记事内容", generalChroniclesContentJt));
|
||||
// }
|
||||
|
||||
generalChroniclesContentJt=new JTextArea(7,26);
|
||||
Placeholder placeholder7 = new Placeholder(generalChroniclesContentJt, "请输入一般记事内容...");
|
||||
generalChroniclesContentJt.setLineWrap(true); //设置文本域中的文本为自动换行
|
||||
generalChroniclesContentJt.setForeground(Color.BLACK); //设置组件的背景色
|
||||
generalChroniclesContentJt.setFont(new Font("微软雅黑",Font.PLAIN,40)); //修改字体样式
|
||||
generalChroniclesContentJt.setBackground(Color.WHITE); //设置按钮背景色
|
||||
JScrollPane generalChroniclesContentJtJsp=new JScrollPane(generalChroniclesContentJt); //将文本域放入滚动窗口
|
||||
Dimension generalChroniclesContentJtSize=generalChroniclesContentJt.getPreferredSize(); //获得文本域的首选大小
|
||||
int generalChroniclesContentJtY = generalChroniclesJly + 120;
|
||||
generalChroniclesContentJtJsp.setBounds(eventDetectionJlx,generalChroniclesContentJtY,1310,generalChroniclesContentJtSize.height+20);
|
||||
jp.add(generalChroniclesContentJtJsp);
|
||||
|
||||
btn = new JButton();
|
||||
btn.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
btn.setForeground(Color.BLACK);
|
||||
btn.setText("提交");
|
||||
btn.addMouseListener(this);
|
||||
int btnX = (dimension.width - 100) / 4;
|
||||
btn.setBounds(btnX, generalChroniclesContentJtY + 450, 200, 100);
|
||||
|
||||
jp.add(weatherLabel);
|
||||
jp.add(weatherJt);
|
||||
jp.add(lowTemperatureLabel);
|
||||
jp.add(lowTemperatureJt);
|
||||
jp.add(temperatureLabel);
|
||||
jp.add(temperatureJt);
|
||||
jp.add(eventDetectionLabel);
|
||||
jp.add(eventDetectionTitleJt);
|
||||
// jp.add(eventDetectionContentJt);
|
||||
jp.add(powerWorkLabel);
|
||||
jp.add(powerWorkTitleJt);
|
||||
// jp.add(powerWorkContentJt);
|
||||
jp.add(resourceCheckLabel);
|
||||
jp.add(resourceCheckTitleJt);
|
||||
// jp.add(resourceCheckContentJt);
|
||||
jp.add(communicationsTestLabel);
|
||||
jp.add(communicationsTestTitleJt);
|
||||
// jp.add(communicationsTestContentJt);
|
||||
jp.add(dailyOperationLabel);
|
||||
jp.add(dailyOperationTitleJt);
|
||||
// jp.add(dailyOperationContentJt);
|
||||
jp.add(dailySubmissionLabel);
|
||||
jp.add(dailySubmissionTitleJt);
|
||||
// jp.add(dailySubmissionContentJt);
|
||||
jp.add(warningDisposalLabel);
|
||||
jp.add(warningDisposalTitleJt);
|
||||
// jp.add(warningDisposalContentJt);
|
||||
jp.add(generalChroniclesLabel);
|
||||
jp.add(generalChroniclesTitleJt);
|
||||
// jp.add(generalChroniclesContentJt);
|
||||
jp.add(btn);
|
||||
return jp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据框中的字体颜色及大小
|
||||
*
|
||||
* @param jtf
|
||||
*/
|
||||
private void setTextFiledColor(JTextField jtf) {
|
||||
jtf.setFont(new Font("微软雅黑", Font.BOLD, 50));
|
||||
jtf.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
JButton temp = (JButton) e.getSource();
|
||||
if (temp.equals(btn)) {
|
||||
List<String> list = getAllField();
|
||||
Boolean check = checkEmpty(list);
|
||||
if (check) {
|
||||
LogBean logBean = getLogBean();
|
||||
insertData(logBean);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(jp, "请检查数据是否填写完毕!", "错误", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LogBean getLogBean() {
|
||||
LogBean bean = new LogBean();
|
||||
bean.setWeather(weatherJt.getText());
|
||||
bean.setMin_temperature(lowTemperatureJt.getText());
|
||||
bean.setMax_temperature(temperatureJt.getText());
|
||||
bean.setEvent_detection_title(eventDetectionTitleJt.getText());
|
||||
bean.setEvent_detection_content(eventDetectionContentJt.getText());
|
||||
bean.setPower_work_title(powerWorkTitleJt.getText());
|
||||
bean.setPower_work_content(powerWorkContentJt.getText());
|
||||
bean.setResource_check_title(resourceCheckTitleJt.getText());
|
||||
bean.setResource_check_content(resourceCheckContentJt.getText());
|
||||
bean.setCommunications_test_title(communicationsTestTitleJt.getText());
|
||||
bean.setCommunications_test_content(communicationsTestContentJt.getText());
|
||||
bean.setDaily_operation_title(dailyOperationTitleJt.getText());
|
||||
bean.setDaily_operation_content(dailyOperationContentJt.getText());
|
||||
bean.setDaily_submission_title(dailySubmissionTitleJt.getText());
|
||||
bean.setDaily_submission_content(dailySubmissionContentJt.getText());
|
||||
bean.setWarning_disposal_title(warningDisposalTitleJt.getText());
|
||||
bean.setWarning_disposal_content(warningDisposalContentJt.getText());
|
||||
bean.setGeneral_chronicles_title(generalChroniclesTitleJt.getText());
|
||||
bean.setGeneral_chronicles_content(generalChroniclesContentJt.getText());
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void insertData(LogBean logBean) {
|
||||
String xml = null;
|
||||
XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
xstream.setMode(XStream.NO_REFERENCES);
|
||||
xstream.alias("log", LogBean.class);
|
||||
try {
|
||||
xml = xstream.toXML(logBean);
|
||||
// 将XML字符串写入文件,并指定字符编码为UTF-8
|
||||
FileOutputStream fos = new FileOutputStream(DataConfig.filePath + "\\log.xml");
|
||||
OutputStreamWriter writer = new OutputStreamWriter(fos, "GBK");
|
||||
writer.write(xml);
|
||||
writer.close();
|
||||
System.out.println("文件保存成功");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (new File(DataConfig.filePath + "\\log.xml").exists()) {
|
||||
JOptionPane.showMessageDialog(jp, "日志保存成功!", "提示", 1);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 URLEncoder 库对字符串进行 utf-8 编码
|
||||
|
||||
public String encodePathVariable(String pathVariable) {
|
||||
String ret = "default";
|
||||
try {
|
||||
ret = URLEncoder.encode(pathVariable, "utf-8");
|
||||
System.out.println(pathVariable + " : " + ret);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<String> getAllField() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(weatherJt.getText() + "");
|
||||
list.add(lowTemperatureJt.getText() + "");
|
||||
list.add(temperatureJt.getText() + "");
|
||||
list.add(eventDetectionTitleJt.getText() + "");
|
||||
list.add(eventDetectionContentJt.getText() + "");
|
||||
list.add(powerWorkTitleJt.getText() + "");
|
||||
list.add(powerWorkContentJt.getText() + "");
|
||||
list.add(resourceCheckTitleJt.getText() + "");
|
||||
list.add(resourceCheckContentJt.getText() + "");
|
||||
list.add(communicationsTestTitleJt.getText() + "");
|
||||
list.add(communicationsTestContentJt.getText() + "");
|
||||
list.add(dailyOperationTitleJt.getText() + "");
|
||||
list.add(dailyOperationContentJt.getText() + "");
|
||||
list.add(dailySubmissionTitleJt.getText() + "");
|
||||
list.add(dailySubmissionContentJt.getText() + "");
|
||||
list.add(warningDisposalTitleJt.getText() + "");
|
||||
list.add(warningDisposalContentJt.getText() + "");
|
||||
list.add(generalChroniclesTitleJt.getText() + "");
|
||||
list.add(generalChroniclesContentJt.getText() + "");
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据是否填充完全
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public Boolean checkEmpty(List<String> list) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (!StringHelper.isEmptyAndNull(list.get(i))) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public JScrollPane view() {
|
||||
return jScroller;
|
||||
}
|
||||
class Placeholder implements FocusListener {
|
||||
private JTextArea textArea;
|
||||
private String placeholder;
|
||||
|
||||
public Placeholder(JTextArea textArea, String placeholder) {
|
||||
this.textArea = textArea;
|
||||
this.placeholder = placeholder;
|
||||
textArea.setText(placeholder);
|
||||
textArea.setForeground(Color.GRAY);
|
||||
textArea.addFocusListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (textArea.getText().equals(placeholder)) {
|
||||
textArea.setText("");
|
||||
textArea.setForeground(Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (textArea.getText().isEmpty()) {
|
||||
textArea.setText(placeholder);
|
||||
textArea.setForeground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue