日期:2014-05-20 浏览次数:20694 次
Object a1[][];
Object name1[] = {"进程名", "到达时间", "服务时间"};
table_total = new JTable(a1, name1);
add(new JScrollPane(table_total), BorderLayout.CENTER);
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
/**
*
* @date 23/11/2012
*/
public class ThreadTimeDemo extends JPanel {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame f = new JFrame("Test");
f.getContentPane().add(new ThreadTimeDemo(), BorderLayout.CENTER);
f.pack();
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
});
}
private JSpinner spinnerThreadCount;
private JTextField totalTime;
private ThreadTimeTableModel model;
private JTable table;
private Action actionStart;
private final ExecutorService executor = Executors.newCachedThreadPool();
ThreadTimeDemo() {
spinnerThreadCount = new JSpinner(new SpinnerNumberModel(20, 1, 20, 1));