Example usage for javax.swing Timer Timer

List of usage examples for javax.swing Timer Timer

Introduction

In this page you can find the example usage for javax.swing Timer Timer.

Prototype

public Timer(int delay, ActionListener listener) 

Source Link

Document

Creates a Timer and initializes both the initial delay and between-event delay to delay milliseconds.

Usage

From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutForm.java

private void createUIComponents() {
    // Create user account panel
    userAccountPanel = new UserAccountPanel();

    // Create timer for filtering the list
    timer = new Timer(400, null);
    timer.setInitialDelay(400);/*from  w ww  . j av  a  2 s  .c om*/
    timer.setActionCommand(CMD_REPO_FILTER_CHANGED);
    timer.setRepeats(false);
}

From source file:es.emergya.ui.gis.popups.SDSDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(i18n.getString("Buttons.send"))) {
        bandejaSalida = send();//from  w  ww. j  a  v a 2  s  .c  o  m

        if (bandejaSalida == null) {
            return;
        }

        notification.setForeground(Color.WHITE);
        progressIcon.setIcon(iconEnviando);
        send.setEnabled(false);
        sds.setEnabled(false);

        SendActionListener listener = new SendActionListener(bandejaSalida);
        final Timer t = new Timer(1000, listener);

        listener.setTimer(t);
        t.start();
    } else if (e.getActionCommand().equals(i18n.getString("Buttons.cancel"))) {
        if (bandejaSalida != null) {
            MessageGenerator.remove(bandejaSalida.getId());
        }

        bandejaSalida = null;
        dispose();
    }
}

From source file:view.QuestionLab.java

/**
 * Creates new form QuestionLab//from w  w w .j a  v a 2  s  .  co  m
 */
public QuestionLab(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    try {

        initComponents();
        submitButton.setVisible(false);
        jCheckBox1.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox4.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox7.setEnabled(false);
        jCheckBox8.setEnabled(false);
        jCheckBox9.setEnabled(false);
        jCheckBox10.setEnabled(false);
        submitButton.setEnabled(false);
        backButton.setEnabled(false);

        controller = ServerConnector.getServerConnector().getStudentController();
        studentObserverImpl = new StudentObserverImpl(this);
        controller.addObserve(studentObserverImpl);
        //controller.onlineNow();
        //displayMessage(Integer.toString(onlineNow));
        muteButton.setEnabled(false);
        setSize(Toolkit.getDefaultToolkit().getScreenSize());
        UIManager.setLookAndFeel(new GraphiteLookAndFeel());

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        date = new Date();
        System.out.println(dateFormat.format(date));
        newDate = dateFormat.format(date);
        JButton buttonArrayListOne[][] = { { jButton1, jButton2, jButton3, jButton4, jButton5 },
                { jButton6, jButton7, jButton8, jButton9, jButton10 },
                { jButton11, jButton12, jButton13, jButton14, jButton15 },
                { jButton16, jButton17, jButton18, jButton19, jButton20 },
                { jButton21, jButton22, jButton23, jButton24, jButton25 },
                { jButton26, jButton27, jButton28, jButton29, jButton30 },
                { jButton31, jButton32, jButton33, jButton34, jButton35 },
                { jButton36, jButton37, jButton38, jButton39, jButton40 },
                { jButton41, jButton42, jButton43, jButton44, jButton45 },
                { jButton46, jButton47, jButton48, jButton49, jButton50 },
                { jButton51, jButton52, jButton53, jButton54, jButton55 },
                { jButton56, jButton57, jButton58, jButton59, jButton60 }

        };

        this.buttonArrayList = buttonArrayListOne;
        System.out.println("MyNIc" + PracticeExamLogIn.studentNic);
        new Timer(1000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                int hour = secondsLeft / 3600;
                int min = secondsLeft / 60 - hour * 60;
                int second = secondsLeft % 60;

                if (hour == 0) {
                    int seconds = secondsLeft % 60;

                    jLabel7.setText(Integer.toString(seconds));

                    jLabel8.setText("Minutes");
                    //   jLabel5.setText("Seconds");
                    jLabel6.setText(Integer.toString(min));

                } else {
                    jLabel6.setText(Integer.toString(hour));
                    jLabel7.setText(Integer.toString(min));
                    jLabel8.setText(Integer.toString(second));

                }
                secondsLeft--;
                if ("0".equals(jLabel6.getText()) && "0".equals(jLabel7.getText())) {
                    //check(); 
                    System.out.println("true");
                }

            }
        }).start();

        submitTextField.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
                char c = e.getKeyChar();
                if (!((c >= 'a') && (c <= 'g') || (c == KeyEvent.VK_SPACE) || (c == KeyEvent.VK_TAB)
                        || (c == KeyEvent.VK_SPACE))) {
                    getToolkit().beep();
                    e.consume();
                }
            }
        });

        try {

            try {
                Exam exam = new Exam(PracticeExamLogIn.studentNic, date, anxCount);
                //    ExamController examController = ServerConnector.getServerConnector().getExamController();
                try {
                    boolean addMarks = ServerConnector.getServerConnector().getExamController().addMarks(exam);
                    // Exam exam = examController.addMarks(PracticeExamLogIn.studentNic, newDate, anxCount);
                    // if (addMarks) {
                    //   JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered successfully !!");
                    //   this.dispose();
                    //    new LogIn(null, true).setVisible(true);

                    //                    } else {
                    //                        JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered failed !!");
                    //                    }
                } catch (ClassNotFoundException | SQLException ex) {
                    Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (NotBoundException | MalformedURLException ex) {
                Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (RemoteException ex) {
            Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NotBoundException | MalformedURLException | RemoteException ex) {
        Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.github.benchdoos.weblocopener.weblocOpener.gui.EditDialog.java

@Override
public void showMessage(String message, int messageValue) {
    errorPanel.setBackground(MessagePushable.getMessageColor(messageValue));

    boolean wasVisible = errorPanel.isVisible();
    errorPanel.setVisible(true);/*w w w  .j av a 2  s. co  m*/
    errorTextPane.setText(message);

    if (!wasVisible) {
        updateSize(SettingsDialog.UpdateMode.BEFORE_HIDE);
    }

    if (messageTimer != null) {
        messageTimer.stop();
    }

    messageTimer = new Timer(DEFAULT_TIMER_DELAY, e -> {
        errorTextPane.setText("");
        errorPanel.setVisible(false);
        updateSize(SettingsDialog.UpdateMode.AFTER_HIDE);
    });
    messageTimer.setRepeats(false);
    messageTimer.start();
}

From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileToolDynamicRangePanel.java

public JPanel getControls() {
    if (controls == null) {
        controls = new JPanel(new BorderLayout());

        JPanel dirButton = new JPanel(new GridLayout(1, 2));
        dirButton.add(moveUpData);/*from   w  w w . j  a va2  s. c o  m*/
        dirButton.add(moveDownData);

        JPanel pointsPanel = new JPanel(new BorderLayout());
        pointsPanel.add(saveData, BorderLayout.NORTH);
        pointsPanel.add(numPoints, BorderLayout.CENTER);
        pointsPanel.add(updatePoints, BorderLayout.EAST);
        pointsPanel.add(showFlattenedButton, BorderLayout.SOUTH);

        JPanel offsetPane = new JPanel(new BorderLayout());
        offsetPane.add(showOffset, BorderLayout.WEST);
        offsetPane.add(offset, BorderLayout.CENTER);

        JPanel temp = new JPanel(new BorderLayout());
        temp.add(offsetPane, BorderLayout.NORTH);
        temp.add(transparance, BorderLayout.CENTER);

        JPanel toolPanel = new JPanel(new BorderLayout());
        toolPanel.add(dirButton, BorderLayout.NORTH);
        toolPanel.add(pointsPanel, BorderLayout.CENTER);
        toolPanel.add(temp, BorderLayout.SOUTH);

        controls.add(toolPanel, BorderLayout.NORTH);

        transparance.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                panel.repaint();

            }
        });
        showOffset.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                panel.repaint();
            }
        });

        offset.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                panel.shapeChanged();
                panel.repaint();
            }

        });
        showFlattenedButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                showFlattenedImage();
            }
        });
        updatePoints.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setDataPoints((Integer) numPoints.getValue());
            }
        });

        moveUPTimer = new Timer(delay, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addValue(1.0f / view.getImage().getImage().getHeight());
            }
        });

        moveDownTimer = new Timer(delay, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addValue(-1.0f / view.getImage().getImage().getHeight());
            }
        });

        moveUpData.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                JButton btn2 = (JButton) e.getSource();
                ButtonModel model = btn2.getModel();
                if (model.isPressed() && !moveUPTimer.isRunning()) {
                    moveUPTimer.start();
                } else if (!model.isPressed() && moveUPTimer.isRunning()) {
                    moveUPTimer.stop();
                }

            }
        });

        moveDownData.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                JButton btn2 = (JButton) e.getSource();
                ButtonModel model = btn2.getModel();
                if (model.isPressed() && !moveDownTimer.isRunning()) {
                    moveDownTimer.start();
                } else if (!model.isPressed() && moveDownTimer.isRunning()) {
                    moveDownTimer.stop();
                }

            }
        });
        moveUpData.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addValue(1.0f / view.getImage().getImage().getHeight());

            }
        });

        moveDownData.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addValue(-1.0f / view.getImage().getImage().getHeight());

            }
        });

        saveData.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    saveData();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
    }

    return controls;
}

From source file:org.leo.benchmark.Benchmark.java

/**
 * Execute the current run code loop times.
 * //from  w w  w.  j  a v a2  s.  c  o m
 * @param run code to run
 * @param loop number of time to run the code
 * @param taskName name displayed at the end of the task
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void execute(BenchRunnable run, int loop, String taskName) {
    System.out.print(taskName + " ... ");
    // set default context
    collection.clear();
    collection.addAll(defaultCtx);
    // warmup
    warmUp();
    isTimeout = false;
    // timeout timer
    Timer timer = new Timer((int) timeout, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            isTimeout = true;
            // to raise a ConcurrentModificationException or a
            // NoSuchElementException to interrupt internal work in the List
            collection.clear();
        }
    });
    timer.setRepeats(false);
    timer.start();
    long startTime = System.nanoTime();
    int i;
    for (i = 0; i < loop && !isTimeout; i++) {
        try {
            run.run(i);
        } catch (Exception e) {
            // on purpose so ignore it
        }
    }
    timer.stop();
    long time = isTimeout ? timeout * 1000000 : System.nanoTime() - startTime;
    System.out.println((isTimeout ? "Timeout (>" + time + "ns) after " + i + " loop(s)" : time + "ns"));
    // restore default context,
    // the collection instance might have been
    // corrupted by the timeout so create a new instance
    try {
        Constructor<? extends Collection> constructor = collection.getClass()
                .getDeclaredConstructor((Class<?>[]) null);
        constructor.setAccessible(true);
        collection = constructor.newInstance();
        // update the reference
        if (collection instanceof List) {
            list = (List<String>) collection;
        }
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    // store the results for display
    Map<Class<? extends Collection<?>>, Long> currentBench = benchResults.get(taskName);
    if (currentBench == null) {
        currentBench = new HashMap<Class<? extends Collection<?>>, Long>();
        benchResults.put(taskName, currentBench);
    }
    currentBench.put((Class<? extends Collection<String>>) collection.getClass(), time);
    // little gc to clean up all the stuff
    System.gc();
}

From source file:com.mirth.connect.connectors.jdbc.DatabaseReader.java

private void update() {
    if (timer == null) {
        timer = new Timer(1000, new UpdateSQLActionListener());
        timer.setRepeats(false);//from w w  w  .  j  a  va  2s .c om
        timer.start();
    } else {
        timer.restart();
    }
}

From source file:edu.ku.brc.af.prefs.PreferencesDlg.java

@Override
public void showPanel(final String name) {
    if (StringUtils.isNotEmpty(name)) {
        Component comp = compsHash.get(name);
        if (comp == currentComp) {
            log.error(String.format("The pref pane by the name '%s' is was not found.", name));
            return;
        }/*from w w w  .  jav a2  s .  c  o m*/

        if (false) {
            boolean makeVis = false;
            Dimension oldSize = null;
            if (currentComp != null) {
                oldSize = currentComp.getSize();
                mainPanel.remove(currentComp);

            } else {
                makeVis = true;
            }

            String hContext = prefPanelsHash.get(name).getHelpContext();
            if (StringUtils.isNotEmpty(hContext)) {
                HelpMgr.registerComponent(helpBtn, hContext);
            }

            if (comp != null) {
                comp.setVisible(makeVis);
                mainPanel.add(comp, BorderLayout.CENTER);
                comp.invalidate();
                doLayout();
                repaint();
                currentComp = comp;
                if (oldSize != null) {
                    Dimension winDim = getSize();
                    winDim.width += currentComp.getPreferredSize().width - oldSize.width;
                    winDim.width = Math.max(winDim.width, 400);
                    winDim.height = Math.max(winDim.height, 250);

                    Dimension pSize = prefsToolbar.getPreferredSize();
                    winDim.width = Math.max(winDim.width, pSize.width + 30);

                    setSize(winDim);
                    currentComp.setSize(new Dimension(currentComp.getPreferredSize().width, oldSize.height));

                    // With Animation
                    //startAnimation(this, comp, currentComp.getPreferredSize().height - oldSize.height, false);

                    ((PrefsPanelIFace) comp).setShadeColor(new Color(255, 255, 255, 255));

                    // Without Animation
                    comp.setVisible(true);
                    winDim.height += currentComp.getPreferredSize().height - oldSize.height;
                    winDim.height = Math.max(winDim.height, 250);
                    setSize(winDim);

                    new Timer(MILLI_SEC_DELAY, new FadeInAnimation(comp, 7)).start();
                }
            }
        } else {
            boolean makeVis = false;
            Dimension oldSize = null;
            if (currentComp != null) {
                oldSize = currentComp.getSize();

            } else {
                makeVis = true;
            }

            String hContext = prefPanelsHash.get(name).getHelpContext();
            if (StringUtils.isNotEmpty(hContext)) {
                HelpMgr.registerComponent(helpBtn, hContext);
            }

            if (comp != null) {
                if (currentComp == null) {
                    comp.setVisible(makeVis);
                    mainPanel.add(comp, BorderLayout.CENTER);
                    comp.invalidate();
                    doLayout();
                    repaint();
                    currentComp = comp;
                    return;
                }

                if (oldSize != null) {
                    ((PrefsPanelIFace) currentComp).setShadeColor(new Color(255, 255, 255, 0));

                    new Timer(MILLI_SEC_DELAY, new FadeOutAnimation(comp, oldSize, 12)).start();
                }
            }

        }
    }
}

From source file:com.all.downloader.p2p.phexcore.download.SeedClient.java

private void initialize() throws FileNotFoundException, IOException, DownloadException {
    doLayout();//  w  w w  .  j av  a 2 s. co m

    PhexCoreImpl phexCore = new PhexCoreImpl();
    Properties phexPros = new Properties();
    phexManager = new PhexDownloader(phexCore);
    // phexManager.init();
    filesToShare = new HashSet<File>();
    shareFileList = new ArrayList<ShareFile>();

    downloadButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // log.error("I'm listening on: " +
            // phexManager.getsWrapper().getPort());
            // File dir = new File(path);
            // searchFilesToAddList(dir);
            // for (File file : filesToShare) {
            // ShareFile shareFile = new ShareFile(file);
            // phexManager.getsWrapper().getSharedFilesService().queueUrnCalculation(shareFile);
            // shareFileList.add(shareFile);
            // }
            // timer.start();
        }
    });

    timer = new Timer(2000, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            log.debug("-----------------------------------------------");
            for (ShareFile shareFile : shareFileList) {
                log.debug("file :: " + shareFile.getFileName());
                log.debug("urnSha1 :: " + "urn:sha1:" + shareFile.getSha1());
                log.debug("size :: " + shareFile.getSystemFile().length());
            }
            log.debug("-----------------------------------------------");
        }
    });
}

From source file:gov.noaa.ncdc.iosp.avhrr.util.AvhrrLevel1B2Netcdf.java

/**
 * 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.//  ww w  . j a v a  2s.c  o  m
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
    // Create a file chooser
    this.setTitle("NCDC sat2netcdf converter");

    aboutDialog = new javax.swing.JDialog();
    aboutButton = new javax.swing.JButton();
    aboutLabel = new javax.swing.JLabel();
    aboutDialog.setTitle("About");
    aboutDialog.setName("aboutDialog"); // NOI18N
    aboutDialog.setSize(250, 200);

    aboutButton.setText("OK");
    aboutButton.setName("aboutButton"); // NOI18N
    aboutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            aboutDialog.hide();
        }
    });

    aboutLabel.setText(
            "<html>\nNCDC sat2netcdf Converter<br> </br>\nCopyright (c) 2008 Work of U.S. Government.<br></br>\nNCDC<br></br>\nContact: ncdc.satorder@noaa.gov\n</html>");

    fc = new JFileChooser();
    fc.setMultiSelectionEnabled(true);

    // output directory file chooser
    outFc = new JFileChooser();
    outFc.setMultiSelectionEnabled(false);
    outFc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    activityMonitor = new Timer(100, new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            convertMonitorActionPerformed(evt);
        }
    });

    menuBar = new JMenuBar();
    logMenu = new JMenu("Log");

    logMenuItem = new JMenuItem("View Log");
    logMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            logDialog.show();
        }
    });
    logMenu.add(logMenuItem);

    menuBar.add(logMenu);
    helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);

    helpMenuItem = new JMenuItem("Help");
    helpMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            helpMenuActionPerformed(evt);
        }
    });
    helpMenu.add(helpMenuItem);
    aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            aboutDialog.show();
        }
    });
    helpMenu.add(aboutMenuItem);

    this.setJMenuBar(menuBar);

    jButton4 = new javax.swing.JButton();
    openButton = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jLabel1 = new javax.swing.JLabel();
    outdirButton = new javax.swing.JButton();
    outdirText = new javax.swing.JTextField();
    jPanel1 = new javax.swing.JPanel();
    allChanCheckBox = new javax.swing.JCheckBox();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    chan1CheckBox = new javax.swing.JCheckBox();
    chan2CheckBox = new javax.swing.JCheckBox();
    chan3CheckBox = new javax.swing.JCheckBox();
    chan4CheckBox = new javax.swing.JCheckBox();
    chan5CheckBox = new javax.swing.JCheckBox();
    rawCheckBox = new javax.swing.JCheckBox();
    radCheckBox = new javax.swing.JCheckBox();
    tempCheckBox = new javax.swing.JCheckBox();
    allVarCheckBox = new javax.swing.JCheckBox();
    qualityCheckBox = new javax.swing.JCheckBox();
    calCheckBox = new javax.swing.JCheckBox();
    latlonCheckBox = new javax.swing.JCheckBox();
    metaCheckBox = new javax.swing.JCheckBox();
    jLabel2 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    convertButton = new javax.swing.JButton();
    exitButton = new javax.swing.JButton();

    jButton4.setText("jButton4");

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    openButton.setText("Select Files");
    openButton.setName("selectButton"); // NOI18N
    openButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            openButtonActionPerformed(evt);
        }
    });

    fm = new FileModel();
    jTable1 = new JTable(fm);
    jTable1.setName("table"); // NOI18N
    jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    setTableCellRenderer(jTable1, new ToolCellRenderer());
    // remove popup for table
    removeItem = new JMenuItem("Remove");
    removeItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            int[] selected = jTable1.getSelectedRows();
            for (int i : selected) {
                logTextArea.append("Removed File: " + fm.getFileAtRow(i).getName() + "\n");
            }
            fm.removeRows(selected);
        }
    });
    popup = new JPopupMenu();
    popup.add(removeItem);
    // Add listener to the jtable so the popup menu can come up.
    // MouseListener popupListener = new PopupListener(jTable1);
    // jTable1.addMouseListener(popupListener);

    jTable1.addMouseListener(new MouseListener() {
        public void mousePressed(MouseEvent e) {
            int button = e.getButton();
            int[] selected = jTable1.getSelectedRows();
            if (button != 1 && selected.length > 0) {
                popup.show(e.getComponent(), e.getX(), e.getY());
            }
        }

        public void mouseClicked(MouseEvent e) {
            int button = e.getButton();
            int column = jTable1.getSelectedColumn();
            if (0 == column && 1 == button) {
                updateOutputSize();
            }
        }

        public void mouseEntered(MouseEvent e) {

        }

        public void mouseExited(MouseEvent e) {

        }

        public void mouseReleased(MouseEvent e) {

        }
    });

    TableColumn col = jTable1.getColumnModel().getColumn(1);
    col.setPreferredWidth(250);
    col = jTable1.getColumnModel().getColumn(3);
    col.setPreferredWidth(100);

    jScrollPane1.setViewportView(jTable1);

    jLabel1.setText("Select output directory");

    outdirButton.setText("Browse");
    outdirButton.setName("outdirButton"); // NOI18N
    outdirButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            outdirButtonActionPerformed(evt);
        }
    });
    outdirText.setName("outdirText"); // NOI18N
    try {
        outdirText.setText(new File(".").getCanonicalPath());
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jPanel1.setName("optionPanel"); // NOI18N

    allChanCheckBox.setText("All Channels");
    allChanCheckBox.setSelected(true);
    allChanCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("jCheckBox1", allChanCheckBox);
            updateFileSize();
        }
    });

    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Channels");

    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel4.setText("Calibration");
    jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel5.setText("Additional Data");
    jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    chan1CheckBox.setText("Channel 1");
    chan1CheckBox.setSelected(true);
    chan1CheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("chan1CheckBox", chan1CheckBox);
            updateFileSize();
        }
    });
    chan2CheckBox.setText("Channel 2");
    chan2CheckBox.setSelected(true);
    chan2CheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("chan2CheckBox", chan2CheckBox);
            updateFileSize();
        }
    });

    chan3CheckBox.setText("Channel 3A/B");
    chan3CheckBox.setSelected(true);
    chan3CheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("chan3CheckBox", chan3CheckBox);
            updateFileSize();
        }
    });

    chan4CheckBox.setLabel("Channel 4");
    chan4CheckBox.setSelected(true);
    chan4CheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("chan4CheckBox", chan4CheckBox);
            updateFileSize();
        }
    });
    chan5CheckBox.setLabel("Channel 5");
    chan5CheckBox.setSelected(true);
    chan5CheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleChannelBoxes("chan5CheckBox", chan5CheckBox);
            updateFileSize();
        }
    });
    rawCheckBox.setText("Raw Data");
    rawCheckBox.setSelected(true);
    rawCheckBox.setToolTipText("Counts for each pixel");
    rawCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleCalibrationCheckBoxes(rawCheckBox);
            updateFileSize();
        }
    });
    radCheckBox.setText("Radiance");
    radCheckBox.setToolTipText("Radiance Values");
    radCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleCalibrationCheckBoxes(radCheckBox);
            updateFileSize();
        }
    });
    tempCheckBox.setText("Brightness Temperature");
    tempCheckBox.setToolTipText("Albedo for visible channels, Brightness Temperature for IR channels");
    tempCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleCalibrationCheckBoxes(tempCheckBox);
            updateFileSize();
        }
    });
    allVarCheckBox.setText("All Variables");
    allVarCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleAllVariablesCheckBox();
            updateFileSize();
        }
    });
    qualityCheckBox.setText("Quality Flags");
    qualityCheckBox.setToolTipText("Quality Variables");
    qualityCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleOtherCheckbox(qualityCheckBox);
            updateFileSize();
        }
    });

    calCheckBox.setText("Calibration Coefficients");
    calCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleOtherCheckbox(calCheckBox);
            updateFileSize();
        }
    });

    jLabel2.setText("Select output options");

    convertButton.setText("Convert");
    convertButton.setName("convertButton"); // NOI18N
    convertButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            convertButtonActionPerformed(evt);
        }
    });

    exitButton.setText("Exit");
    exitButton.setName("exitButton"); // NOI18N
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });

    // help dialog
    helpDialog = new javax.swing.JDialog();
    helpCloseButton = new javax.swing.JButton("Close");
    helpScrollPane = new javax.swing.JScrollPane();

    //      helpEditorPane = new javax.swing.JEditorPane("text/rtf", helpText);
    helpEditorPane = new javax.swing.JEditorPane();
    helpEditorPane.setContentType("text/html");
    InputStream stream = null;
    try {
        stream = AvhrrLevel1B2Netcdf.class.getResourceAsStream("/help.html");
        if (stream != null) {
            helpEditorPane.read(stream, "html");
        }
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    helpScrollPane.setViewportView(helpEditorPane);
    helpDialog.setSize(450, 500);
    helpCloseButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            helpDialog.dispose();
        }
    });

    // Log Dialog
    logDialog = new javax.swing.JDialog();
    logScrollPane = new javax.swing.JScrollPane();
    logTextArea = new javax.swing.JTextArea();
    logCloseButton = new javax.swing.JButton();
    clearButton = new javax.swing.JButton();

    logDialog.setTitle("Log");
    logDialog.setName("logDialog"); // NOI18N
    logDialog.setSize(450, 500);
    logScrollPane.setName("logScrollPane"); // NOI18N

    logTextArea.setColumns(20);
    logTextArea.setRows(5);
    logTextArea.setName("logTextArea"); // NOI18N
    logScrollPane.setViewportView(logTextArea);

    logCloseButton.setText("Close");
    logCloseButton.setName("logCloseButton"); // NOI18N
    logCloseButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            logDialog.hide();
        }
    });

    clearButton.setText("Clear");
    clearButton.setName("clearButton"); // NOI18N
    clearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            logTextArea.setText("");
        }
    });

    latlonCheckBox.setText("Lat/Lon");
    latlonCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleLatLonCheckbox();
            updateFileSize();
        }
    });

    metaCheckBox.setText("Other metadata");
    metaCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handleMetadataCheckbox();
            updateFileSize();
        }
    });

    jLabel2.setText("Select output options");

    convertButton.setText("Convert");
    convertButton.setName("convertButton");

    exitButton.setText("Exit");
    exitButton.setName("exitButton");
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });

    jLabel2.setText("Select output options"); // NOI18N

    convertButton.setText("Convert"); // NOI18N
    convertButton.setName("convertButton"); // NOI18N

    exitButton.setText("Exit"); // NOI18N
    exitButton.setName("exitButton"); // NOI18N
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });

    jLabel6.setFont(new java.awt.Font("Dialog", 1, 11));
    jLabel6.setText("Estimated output size: ");

    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap().add(jPanel1Layout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(chan5CheckBox)
                    .add(jPanel1Layout.createSequentialGroup().add(jPanel1Layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel1Layout.createSequentialGroup().add(jPanel1Layout
                                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jPanel1Layout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,
                                                    false)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, allChanCheckBox,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    Short.MAX_VALUE))
                                    .add(chan1CheckBox).add(chan2CheckBox)).add(36, 36, 36)
                                    .add(jPanel1Layout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                            .add(radCheckBox)
                                            .add(tempCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    163, Short.MAX_VALUE)
                                            .add(rawCheckBox).add(jLabel4,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    Short.MAX_VALUE)))
                            .add(chan3CheckBox).add(chan4CheckBox))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(metaCheckBox).add(latlonCheckBox).add(allVarCheckBox)
                                    .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113,
                                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(qualityCheckBox).add(calCheckBox))))
                    .add(67, 67, 67)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel3).add(jLabel5).add(jLabel4,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(allChanCheckBox).add(allVarCheckBox).add(rawCheckBox))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(chan1CheckBox).add(qualityCheckBox).add(radCheckBox))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(chan2CheckBox).add(calCheckBox).add(tempCheckBox,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(chan3CheckBox).add(latlonCheckBox))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(chan4CheckBox).add(metaCheckBox))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(chan5CheckBox)
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    jLabel2.setText("Select output options"); // NOI18N

    convertButton.setText("Convert"); // NOI18N
    convertButton.setName("convertButton"); // NOI18N

    exitButton.setText("Exit"); // NOI18N
    exitButton.setName("exitButton"); // NOI18N
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });

    jLabel6.setFont(new java.awt.Font("Dialog", 1, 11));
    jLabel6.setText("Estimated output size: ");

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
                            .add(layout.createSequentialGroup().add(outdirButton)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(outdirText,
                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE))
                            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
                            .add(openButton)
                            .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 291,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(layout.createSequentialGroup().add(convertButton)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel6,
                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE))
                            .add(exitButton).add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    531, Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout
            .createSequentialGroup().addContainerGap().add(openButton)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 173,
                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel1)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(outdirButton).add(
                    outdirText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 27,
                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15,
                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false).add(convertButton)
                    .add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(exitButton).add(12, 12, 12)));
    // log dialog layout
    org.jdesktop.layout.GroupLayout logDialogLayout = new org.jdesktop.layout.GroupLayout(
            logDialog.getContentPane());
    logDialog.getContentPane().setLayout(logDialogLayout);
    logDialogLayout.setHorizontalGroup(
            logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                    org.jdesktop.layout.GroupLayout.TRAILING,
                    logDialogLayout.createSequentialGroup().addContainerGap()
                            .add(logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, logScrollPane,
                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                                    .add(logDialogLayout.createSequentialGroup().add(clearButton)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                            .add(logCloseButton)))
                            .addContainerGap()));
    logDialogLayout.setVerticalGroup(logDialogLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, logDialogLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(logScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                    .add(18, 18, 18)
                    .add(logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(logCloseButton).add(clearButton))
                    .addContainerGap()));

    // help dialog layout
    org.jdesktop.layout.GroupLayout helpDialogLayout = new org.jdesktop.layout.GroupLayout(
            helpDialog.getContentPane());
    helpDialog.getContentPane().setLayout(helpDialogLayout);
    helpDialogLayout.setHorizontalGroup(
            helpDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                    org.jdesktop.layout.GroupLayout.TRAILING,
                    helpDialogLayout.createSequentialGroup().addContainerGap()
                            .add(helpDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, helpScrollPane,
                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                                    .add(helpDialogLayout.createSequentialGroup()
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                            .add(helpCloseButton)))
                            .addContainerGap()));
    helpDialogLayout.setVerticalGroup(helpDialogLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, helpDialogLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(helpScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                    .add(18, 18, 18).add(helpDialogLayout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(helpCloseButton))
                    .addContainerGap()));

    // about dialog layout
    org.jdesktop.layout.GroupLayout aboutDialogLayout = new org.jdesktop.layout.GroupLayout(
            aboutDialog.getContentPane());
    aboutDialog.getContentPane().setLayout(aboutDialogLayout);
    aboutDialogLayout.setHorizontalGroup(
            aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                    org.jdesktop.layout.GroupLayout.TRAILING,
                    aboutDialogLayout.createSequentialGroup().addContainerGap()
                            .add(aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, aboutLabel,
                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
                                    .add(aboutButton))
                            .addContainerGap()));
    aboutDialogLayout.setVerticalGroup(
            aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                    org.jdesktop.layout.GroupLayout.TRAILING,
                    aboutDialogLayout.createSequentialGroup().addContainerGap()
                            .add(aboutLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 35, Short.MAX_VALUE)
                            .add(aboutButton).add(21, 21, 21)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    pack();

    JOptionPane.showMessageDialog(this,
            "Warning! \nThis program is untested.\nPlease read help file for\nsupported files, limitations and license.\n");
    //            + "Please view Help for more information.");
}