package com.
import java.text.SimpleDateFormat;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JOptionPane;
import javax.swing.JComboBox;
import java.util.Vector;
import java.util.Date;
import com.
import com.
public class BasePanel extends JPanel{
protected MainFrame mf;
protected BuinessAction buinessAction;
protected JTextField txtTime;
public BasePanel( MainFrame mFrame ){
this.mf = mFrame;
setLayout( null );
}
public void startTime( JTextField txtTime ){
this.txtTime = txtTime;
new java.util.Timer( (int)1000, new BasePanel_Timer_actionAdapter( this ) ).start();
}
/**输出错误提示*/
public void showError( Exception ex, String title ){
JOptionPane.showMessageDialog( this, "错误代码:" + ex.getMessage(), title,
JOptionPane.ERROR_MESSAGE );
}
/**初始化cobCompterId中的是否可用机器号列表*/
public void panelInit( JComboBox cobComputerId, boolean is ){
cobComputerId.removeAllItems();
buinessAction = new BuinessAction();
Vector vecComputerId = buinessAction.getUsebleComputerIds( is );
for( int i = 0; i < vecComputerId.size(); i++ ){
cobComputerId.addItem( vecComputerId.get( i ) );
}
cobComputerId.setSelectedIndex( 0 );
}
/**更新当前时间*/
public void nowTime( ActionEvent e ){
Date nowTime = new Date();
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
String nowStr = sdf.format( nowTime );
this.txtTime.setText( nowStr );
}
}
class BasePanel_Timer_actionAdapter implements ActionListener{
private BasePanel adatee;
public BasePanel_Timer_actionAdapter( BasePanel adatee ){
this.adatee = adatee;
}
public void actionPerformed( ActionEvent e ){
adatee.nowTime( e );
}
}