📄 publicmethod.java.svn-base
字号:
headerWidth = comp.getPreferredSize().width;
longValues[i] = " " + longValues[i] + " ";
JTable m_table = new JTable(new DefaultTableModel());
comp = (m_table.getDefaultRenderer(String.class)).
getTableCellRendererComponent(table, longValues[i], false, false, 0,
i);
cellWidth = comp.getPreferredSize().width;
column.setPreferredWidth(Math.max(headerWidth, cellWidth));
}
}
else {
System.out.println("initcolumnsizes()--------------");
for (int i = 0; i < model.getColumnCount(); i++) {
System.out.println("i = " + i);
column = table.getColumnModel().getColumn(i);
longValues[i] = " " + longValues[i] + " ";
System.out.println("model.getColumnClass(i) = " +
model.getColumnClass(i));
System.out.println(
"table.getDefaultRenderer(model.getColumnClass(i)) = " +
table.getDefaultRenderer(model.getColumnClass(i)));
comp = table.getDefaultRenderer(model.getColumnClass(i)).
getTableCellRendererComponent(table, longValues[i], false, false, 0,
i);
headerWidth = comp.getPreferredSize().width;
System.out.println("class:" + model.getColumnClass(i).getName());
Component compString = table.getDefaultRenderer(model.getColumnClass(i)).
getTableCellRendererComponent(table,
new String("ssssssssssssssssss"), false, false,
0, i);
int StringCompWidth = compString.getPreferredSize().width;
column.setPreferredWidth(java.lang.Math.max(headerWidth,
StringCompWidth));
}
}
}
public static void ShowDialogs(MouseEvent e, JTable taskTable) {
TableColumn m_TableColumn1 = taskTable.getColumn("序号");
int tcw1 = m_TableColumn1.getPreferredWidth();
TableColumn m_TableColumn2 = taskTable.getColumn("名称");
int tcw2 = m_TableColumn2.getPreferredWidth();
TableColumn m_TableColumn3 = taskTable.getColumn("任务类型");
int tcw3 = m_TableColumn3.getPreferredWidth();
TableColumn m_TableColumn4 = taskTable.getColumn("起始时间");
int tcw4 = m_TableColumn4.getPreferredWidth();
TableColumn m_TableColumn5 = taskTable.getColumn("终止时间");
int tcw5 = m_TableColumn5.getPreferredWidth();
int x = e.getX();
if (x >= (tcw1 + tcw2) && x < (tcw1 + tcw2 + tcw3)) { //任务类型
PublicMethod.m_taskTable = taskTable;
PublicMethod.ColumnIndex = 2;
DataRecruitTableModel m_model = (DataRecruitTableModel) (taskTable.
getModel());
ArrayList m_list = new ArrayList();
for (int k = 0; k < m_model.getRowCount(); k++) {
Object m_obj = m_model.getValueAt(k, 1);
if (m_obj instanceof MyTerminalListElement) {
terminal m_Allready_add_term = ( (MyTerminalListElement) m_obj).
getTerminal();
m_list.add(m_Allready_add_term);
}
if (m_obj instanceof MyMeterListElement) {
meter m_meter = ( (MyMeterListElement) m_obj).getMeter();
terminal m_terminal = (terminal) (CollectorDefine.m_HashTerminal.
get(new Long(m_meter.getTerminalId())));
m_list.add(m_terminal);
}
}
FuncListSetDialog m_FuncListSetDialog = null;
m_FuncListSetDialog = new FuncListSetDialog(null, false, m_list);
System.out.println("!!!!!!!!!!! ^^^^^^^^^^^^^^ &&&&&&&&&&&&&&");
PublicMethod.m_FuncListSetDialog = null;
PublicMethod.m_FuncListSetDialog = m_FuncListSetDialog;
PublicMethod.m_FuncListSetDialog.show();
}
//pzy 1228
/*
else if (x >= (tcw1 + tcw2 + tcw3) && x < (tcw1 + tcw2 + tcw3 + tcw4)) { //起始时间
PublicMethod.m_taskTable = taskTable;
PublicMethod.ColumnIndex = 3;
TimeSetDialog m_TimeSetDialog = null;
if (PublicMethod.m_TimeSetDialog == null) {
m_TimeSetDialog = new TimeSetDialog(null, true);
PublicMethod.m_TimeSetDialog = m_TimeSetDialog;
}
else {
m_TimeSetDialog = PublicMethod.m_TimeSetDialog;
m_TimeSetDialog.initList();
}
m_TimeSetDialog.show();
}
else if (x >= (tcw1 + tcw2 + tcw3 + tcw4) &&
x < (tcw1 + tcw2 + tcw3 + tcw4 + tcw5)) { //终止时间
PublicMethod.m_taskTable = taskTable;
PublicMethod.ColumnIndex = 4;
TimeSetDialog m_TimeSetDialog = null;
if (PublicMethod.m_TimeSetDialog == null) {
m_TimeSetDialog = new TimeSetDialog(null, true);
PublicMethod.m_TimeSetDialog = m_TimeSetDialog;
}
else {
m_TimeSetDialog = PublicMethod.m_TimeSetDialog;
m_TimeSetDialog.initList();
}
m_TimeSetDialog.show();
}
*/
//pzy 1228
else if (x >= (tcw1 + tcw2 + tcw3) && x < (tcw1 + tcw2 + tcw3 + tcw4)) { //起始时间
PublicMethod.m_taskTable = taskTable;
PublicMethod.ColumnIndex = 3;
CalTimeSetDialog m_CalTimeSetDialog = null;
m_CalTimeSetDialog = new CalTimeSetDialog(null, true);
PublicMethod.m_CalTimeSetDialog = m_CalTimeSetDialog;
m_CalTimeSetDialog.show();
}
else if (x >= (tcw1 + tcw2 + tcw3 + tcw4) &&
x < (tcw1 + tcw2 + tcw3 + tcw4 + tcw5)) { //终止时间
PublicMethod.m_taskTable = taskTable;
PublicMethod.ColumnIndex = 4;
CalTimeSetDialog m_CalTimeSetDialog = null;
m_CalTimeSetDialog = new CalTimeSetDialog(null, true);
PublicMethod.m_CalTimeSetDialog = m_CalTimeSetDialog;
m_CalTimeSetDialog.show();
}
else {
return;
}
}
public static String StringTime(long time) { //time ---秒
Date dd = new Date(time * 1000l); //time---毫秒
int year = dd.getYear() + 1900;
int cur_year = new Date(System.currentTimeMillis()).getYear() + 1900;
if (year <= cur_year - 50 || year > cur_year + 50) {
return "未定义";
}
String yearString = (new Integer(year)).toString();
int mm = dd.getMonth();
String month = null;
if ( (mm + 1) < 10) {
month = "0" + (new Integer(mm + 1)).toString();
}
else {
month = (new Integer(mm + 1)).toString();
}
String day = (new Integer(dd.getDate())).toString();
if (dd.getDate() < 10) {
day = "0" + day;
}
String hour = (new Integer(dd.getHours())).toString();
if (dd.getHours() < 10) {
hour = "0" + hour;
}
String min = (new Integer(dd.getMinutes())).toString();
if (dd.getMinutes() < 10) {
min = "0" + min;
}
String date = year + "/" + month + "/" + day + " " + hour + ":" + min;
return date;
}
public static String StringTimeSecond(long time) { //time ---秒
Date dd = new Date(time * 1000l); //time---毫秒
int year = dd.getYear() + 1900;
int cur_year = new Date(System.currentTimeMillis()).getYear() + 1900;
if (year <= cur_year - 50 || year > cur_year + 50) {
return "未定义";
}
String yearString = (new Integer(year)).toString();
int mm = dd.getMonth();
String month = null;
if ( (mm + 1) < 10) {
month = "0" + (new Integer(mm + 1)).toString();
}
else {
month = (new Integer(mm + 1)).toString();
}
String day = (new Integer(dd.getDate())).toString();
if (dd.getDate() < 10) {
day = "0" + day;
}
String hour = (new Integer(dd.getHours())).toString();
if (dd.getHours() < 10) {
hour = "0" + hour;
}
String min = (new Integer(dd.getMinutes())).toString();
if (dd.getMinutes() < 10) {
min = "0" + min;
}
String second = (new Integer(dd.getSeconds())).toString();
if (dd.getSeconds() < 10) {
second = "0" + second;
}
String date = year + "/" + month + "/" + day + " " + hour + ":" + min +
":" + second;
return date;
}
public static void WriteToFile(String filename, String m_String) {
//String pathname = "d:\\pbs_jiangsu\\log\\"+ filename+".txt";
File m_exfile = new File(filename);
try {
if (!m_exfile.exists()) {
m_exfile.createNewFile();
}
FileWriter fw = new FileWriter(m_exfile, true);
PrintWriter pw = new PrintWriter(fw);
pw.println(m_String);
fw.close();
pw.close();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
/*
public static terminal copyTerminal(terminal m_terminal){
terminal m_term = new terminal();
}
*/
public static void main(String[] args) {
PublicMethod m_method = new PublicMethod();
String m_string = m_method.StringTimeSecond(System.currentTimeMillis() /
1000l);
m_method.WriteToFile("c:\\temp\\syslog.txt", m_string);
}
public static JTable m_taskTable = null;
public static TimeSetDialog m_TimeSetDialog = null;
public static CalTimeSetDialog m_CalTimeSetDialog = null;
public static int ColumnIndex = 0;
public static terminal LatestSetParaTerm = null;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -