/* * TimingFrame.java * * Created on April 12, 2005, 10:12 PM */ package sorttimer; /** * * @author levenick */ public class TimingFrame extends java.awt.Frame { /** Creates new form TimingFrame */ public TimingFrame() { initComponents(); setBounds(10,10,500,400); show(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents theTA = new java.awt.TextArea(); bbsortButton = new java.awt.Button(); inssortButton = new java.awt.Button(); setLayout(null); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); add(theTA); theTA.setBounds(20, 30, 380, 230); bbsortButton.setLabel("Bubble"); bbsortButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bbsortButtonActionPerformed(evt); } }); add(bbsortButton); bbsortButton.setBounds(50, 270, 57, 24); inssortButton.setLabel("Insertion"); inssortButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { inssortButtonActionPerformed(evt); } }); add(inssortButton); inssortButton.setBounds(250, 270, 64, 24); pack(); }//GEN-END:initComponents private void inssortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inssortButtonActionPerformed theTA.append("\nInsertion sort\n"); timeEm(new InsertionSort()); } private void timeEm(AbstractSort theSort) { for (int n=1000; n<10000; n *=2) { SortTimer theTimer = new SortTimer(theSort, new MyList(n)); theTA.append(theTimer.time() + "\n"); } }//GEN-LAST:event_inssortButtonActionPerformed private void bbsortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bbsortButtonActionPerformed theTA.append("\nBubble sort\n"); timeEm(new InsertionSort()); }//GEN-LAST:event_bbsortButtonActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.Button bbsortButton; private java.awt.Button inssortButton; private java.awt.TextArea theTA; // End of variables declaration//GEN-END:variables }