private void btnInsertVarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertVarActionPerformed

        if (tableVars.getSelectedRowCount() != 0) {
            //Add variable to the current cursor position.
            int oldCaret = txtExpression.getCaretPosition();
            String varName = ((DefaultTableModel) tableVars.getModel()).getValueAt(tableVars.getSelectedRow(), 0).toString();
            txtExpression.setText(txtExpression.getText().substring(0, oldCaret) + "$" + varName + txtExpression.getText().substring(oldCaret));
            txtExpression.setCaretPosition(oldCaret + varName.length() + 1);
            txtExpression.grabFocus();
        }
    }//GEN-LAST:event_btnInsertVarActionPerformed