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

📄 editdialog.java

📁 用java 实现的一个任务管理器
💻 JAVA
字号:
package com.fang.client.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import com.fang.client.config.FTaskConfig;
import com.fang.commom.util.DateChooserJButton;
import com.fang.commom.util.StringParser;
import com.fang.common.core.FTask;



public class EditDialog extends JDialog {

	private static final long serialVersionUID = 1287153625698328002L;

	public   FTask temptask;
	
//	private JTextField textField_5;
	private JComboBox comboBox;
	private JTextField textField_4;
//	private JTextField textField_3;
	private DateChooserJButton textField_3;
	private JTextField textField_2;
	private JTextField textField_1;
	private JTextField textField;
	public static void main(String args[]) {
		try {
			EditDialog dialog = new EditDialog();
			dialog.addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}
			});
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	public EditDialog() {
		super();
		getContentPane().setLayout(null);
		setBounds(100, 100, 500, 400);

		final JLabel label = new JLabel();
		label.setText("任务编号");
		label.setBounds(131, 57, 66, 18);
		getContentPane().add(label);

		textField = new JTextField();
		textField.setEditable(false);
		textField.setBounds(235, 55, 87, 22);
		getContentPane().add(textField);

		final JLabel label_1 = new JLabel();
		label_1.setText("任务名称");
		label_1.setBounds(131, 96, 66, 18);
		getContentPane().add(label_1);

		textField_1 = new JTextField();
		textField_1.setBounds(235, 94, 87, 22);
		getContentPane().add(textField_1);

		final JLabel label_2 = new JLabel();
		label_2.setText("命令参数");
		label_2.setBounds(131, 136, 66, 18);
		getContentPane().add(label_2);

		textField_2 = new JTextField();
		textField_2.setBounds(235, 134, 247, 22);
		getContentPane().add(textField_2);

		final JLabel label_3 = new JLabel();
		label_3.setText("开始时间");
		label_3.setBounds(131, 174, 66, 18);
		getContentPane().add(label_3);

		textField_3 = new DateChooserJButton();
		textField_3.setBounds(235, 172, 179, 22);
		getContentPane().add(textField_3);

		final JLabel label_4 = new JLabel();
		label_4.setText("间隔周期");
		label_4.setBounds(131, 215, 66, 18);
		getContentPane().add(label_4);

		textField_4 = new JTextField();
		textField_4.setBounds(235, 213, 87, 22);
		getContentPane().add(textField_4);

		final JLabel label_5 = new JLabel();
		label_5.setText("任务类型");
		label_5.setBounds(131, 252, 66, 18);
		getContentPane().add(label_5);

	//	textField_5 = new JTextField();
	//	textField_5.setBounds(235, 250, 87, 22);
	//	getContentPane().add(textField_5);

		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"linux执行命令","url访问命令"}));
		comboBox.setBounds(235, 250, 106, 22);
		getContentPane().add(comboBox);
		
		final JButton button = new JButton();
		button.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				//TODO 任务修改完成后提交处理
				temptask.setTaskname(textField_1.getText().trim());
				temptask.setCmdParam(StringParser.parseByBlank(textField_2.getText().trim()));
				temptask.setStarttime(StringParser.parseToDate(textField_3.getText().trim()).getTime());
				temptask.setInternal(Integer.parseInt(textField_4.getText().trim())*60);//*60把分转化成秒
				temptask.setCmdType(comboBox.getSelectedIndex());
				temptask.setStatus(Constants.NOT_START);
				System.out.println("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
		        System.out.println("row"+BtnActionListener.rowselected+"selected!!");
				
				FTaskConfig config=new FTaskConfig();
				if(config.updateTask(temptask)==1){
					//TODO把更新内容显示出来
					TableModelMirror tableModel=TableModelMirror.newInstance();
					//tableModel.fireTableDataChanged();
					tableModel.fireTableRowsUpdated(BtnActionListener.rowselected, BtnActionListener.rowselected);
					//tableModel.fireTableDataChanged();
				}else {
					//TODO 提示用户操作失败
          		  JOptionPane.showMessageDialog(null,
          	              "操作失败,请稍候再试!!", "alert", JOptionPane.ERROR_MESSAGE);
				};
				
				
				
			}
		});
		button.setText("提交");
		button.setBounds(91, 298, 106, 28);
		getContentPane().add(button);

		final JButton button_1 = new JButton();
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				EditDialog.this.dispose();//引用外部类的this。 
			}
		});
		button_1.setText("取消");
		button_1.setBounds(235, 298, 106, 28);
		getContentPane().add(button_1);

		final JLabel label_6 = new JLabel();
		label_6.setText("(单位:分钟)");
		label_6.setBounds(341, 215, 73, 18);
		getContentPane().add(label_6);
		//
	}


	public JComboBox getComboBox() {
		return comboBox;
	}





	public JTextField getTextField_4() {
		return textField_4;
	}





	public DateChooserJButton getTextField_3() {
		return textField_3;
	}




	public JTextField getTextField_2() {
		return textField_2;
	}




	public JTextField getTextField_1() {
		return textField_1;
	}




	public JTextField getTextField() {
		return textField;
	}


	public FTask getTemptask() {
		return temptask;
	}


	public void setTemptask(FTask temptask) {
		this.temptask = temptask;
	}



}

⌨️ 快捷键说明

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