JFileChooser with confirmation dialog

Thanks for the answers, but I found another workaround, overriding the approveSelection() of the JFileChooser, this way: JFileChooser example = new JFileChooser(){ @Override public void approveSelection(){ File f = getSelectedFile(); if(f.exists() && getDialogType() == SAVE_DIALOG){ int result = JOptionPane.showConfirmDialog(this,”The file exists, overwrite?”,”Existing file”,JOptionPane.YES_NO_CANCEL_OPTION); switch(result){ case JOptionPane.YES_OPTION: super.approveSelection(); return; case JOptionPane.NO_OPTION: return; case JOptionPane.CLOSED_OPTION: return; case … Read more

How do I enable :confirmable in Devise?

to “enable” confirmable, you just need to add it to your model, e.g.: class User # … devise :confirmable , …. # … end after that, you’ll have to create and run a migration which adds the required columns to your model: # rails g migration add_confirmable_to_devise class AddConfirmableToDevise < ActiveRecord::Migration def self.up add_column :users, … Read more

Easy way to make a confirmation dialog in Angular?

Method 1 One simple way to confirm is to use the native browser confirm alert. The template can have a button or link. <button type=button class=”btn btn-primary” (click)=”clickMethod(‘name’)”>Delete me</button> And the component method can be something like below. clickMethod(name: string) { if(confirm(“Are you sure to delete “+name)) { console.log(“Implement delete functionality here”); } } Method … Read more

How to implement a confirmation (yes/no) DialogPreference?

That is a simple alert dialog, Federico gave you a site where you can look things up. Here is a short example of how an alert dialog can be built. new AlertDialog.Builder(this) .setTitle(“Title”) .setMessage(“Do you really want to whatever?”) .setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(MainActivity.this, “Yaay”, Toast.LENGTH_SHORT).show(); }}) … Read more

Swift alert view with OK and Cancel: which button tapped?

If you are using iOS8, you should be using UIAlertController — UIAlertView is deprecated. Here is an example of how to use it: var refreshAlert = UIAlertController(title: “Refresh”, message: “All data will be lost.”, preferredStyle: UIAlertControllerStyle.Alert) refreshAlert.addAction(UIAlertAction(title: “Ok”, style: .Default, handler: { (action: UIAlertAction!) in print(“Handle Ok logic here”) })) refreshAlert.addAction(UIAlertAction(title: “Cancel”, style: .Cancel, handler: … Read more

How do I set up email confirmation with Devise?

1. Make sure you include confirmable in Model.devise call class User < ActiveRecord::Base devise :database_authenticatable, :confirmable … end 2. Make sure you add confirmable to the user migration create_table :users do |t| t.database_authenticatable t.confirmable … end If you’re using devise 2.0+ this fails because devise no longer provides migration helpers, and so t.confirmable raises an … Read more

In Bash, how to add “Are you sure [Y/n]” to any command or alias?

These are more compact and versatile forms of Hamish’s answer. They handle any mixture of upper and lower case letters: read -r -p “Are you sure? [y/N] ” response case “$response” in [yY][eE][sS]|[yY]) do_something ;; *) do_something_else ;; esac Or, for Bash >= version 3.2: read -r -p “Are you sure? [y/N] ” response if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)