Java Code Examples for javax.swing.JOptionPane#showOptionDialog()

The following examples show how to use javax.swing.JOptionPane#showOptionDialog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Control.java    From JAVA-MVC-Swing-Monopoly with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * 
 * ʹ��ң�����ӿ�
 * 
 * 
 */
private void useControlDiceCard(Card card) {
	Object[] options = { "1��", "2��", "3��", "4��", "5��", "6��", "����ѡ��" };
	int response = JOptionPane.showOptionDialog(null,
			"ȷ��ʹ��\"ң�����ӿ�\"ң�����ӵ���?", "��Ƭʹ�ý׶�.", JOptionPane.YES_OPTION,
			JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
	if (response == -1 || response == 6) {
		return;
	} else {
		// ʹ��
		this.run.setPoint(response);
		// �����ı���ʾ
		this.textTip.showTextTip(card.getOwner(), card.getOwner().getName()
				+ " ʹ���� \"ң�����ӿ�\".", 2);
		// ����ȥ��Ƭ
		card.getOwner().getCards().remove(card);
	}
}
 
Example 2
Source File: AIMerger.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void closeApplication() {
  int response = JOptionPane.showOptionDialog(myCP, "Exit AIMerger?", "Exit",
      JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null,
      JOptionPane.YES_OPTION);
  switch (response) {
    default:
      // This should never happen
      throw new IllegalArgumentException("not an option");
    case JOptionPane.CLOSED_OPTION:
    case JOptionPane.CANCEL_OPTION:
      offerNewMerge();
      break;
    case JOptionPane.OK_OPTION:
      System.exit(0);
      break;
  }
}
 
Example 3
Source File: Config.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
private static void catchException() {
	// Cant write to the log here as it is not initilized
	//Log.println("Could not read properties file. Likely Corrupt.");
	Object[] options = {"Yes",
       "Exit"};
	int n = JOptionPane.showOptionDialog(
			MainWindow.frame,
			"Could not read properties file. If this is a new release then the format has probablly been extended.\n"
			+ "Should I create a new properties file after reading as much as possible from the existing one?",
			"Error Loading " + Config.homeDirectory + File.separator + propertiesFileName,
		    JOptionPane.YES_NO_OPTION,
		    JOptionPane.ERROR_MESSAGE,
		    null,
		    options,
		    options[0]);
				
	if (n == JOptionPane.YES_OPTION) {
		save();
		Log.println("Created new properties file.");
	} else
		System.exit(1);

}
 
Example 4
Source File: UiUtils.java    From pgptool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param messageType
 *            one of the JOptionPane ERROR_MESSAGE, INFORMATION_MESSAGE,
 *            WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
 */
public static void messageBox(ActionEvent originEvent, String msg, String title, int messageType) {
	Object content = buildMessageContentDependingOnLength(msg);

	Component parent = findWindow(originEvent);
	if (messageType != JOptionPane.ERROR_MESSAGE) {
		JOptionPane.showMessageDialog(parent, content, title, messageType);
		return;
	}

	Object[] options = { text("action.ok"), text("phrase.saveMsgToFile") };
	if ("action.ok".equals(options[0])) {
		// if app context wasn't started MessageSource wont be available
		options = new String[] { "OK", "Save message to file" };
	}

	int result = JOptionPane.showOptionDialog(parent, content, title, JOptionPane.YES_NO_OPTION, messageType, null,
			options, JOptionPane.YES_OPTION);
	if (result == JOptionPane.YES_OPTION || result == JOptionPane.CLOSED_OPTION) {
		return;
	}

	// Save to file
	saveMessageToFile(parent, msg);
}
 
Example 5
Source File: TableExample.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Brigs up a JDialog using JOptionPane containing the connectionPanel.
 * If the user clicks on the 'Connect' button the connection is reset.
 */
void activateConnectionDialog() {
    if (JOptionPane.showOptionDialog(tableAggregate, connectionPanel,
            ConnectTitle,
            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
            null, ConnectOptionNames, ConnectOptionNames[0]) == 0) {
        connect();
        frame.setVisible(true);
    } else if (!frame.isVisible()) {
        System.exit(0);
    }
}
 
Example 6
Source File: RLangEditor.java    From Processing.R with GNU General Public License v3.0 5 votes vote down vote up
/**
 * TODO(James Gilles): Create this! Create export GUI and hand off results to performExport()
 */
public void handleExportApplication() {
  // Leaving this here because it seems like it's more the editor's responsibility
  if (sketch.isModified()) {
    final Object[] options = {"OK", "Cancel"};
    final int result = JOptionPane.showOptionDialog(this, "Save changes before export?", "Save",
        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
    if (result == JOptionPane.OK_OPTION) {
      handleSave(true);
    } else {
      statusNotice("Export canceled, changes must first be saved.");
    }
  }
}
 
Example 7
Source File: BugTrackerGithub.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public boolean showRemoveDialogue(BugTrackerGithubConfigParams e) {
    JCheckBox removeWithoutConfirmationCheckBox =
            new JCheckBox(REMOVE_DIALOG_CHECKBOX_LABEL);
    Object[] messages = {REMOVE_DIALOG_TEXT, " ", removeWithoutConfirmationCheckBox};
    int option =
            JOptionPane.showOptionDialog(
                    View.getSingleton().getMainFrame(),
                    messages,
                    REMOVE_DIALOG_TITLE,
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    new String[] {
                        REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
                        REMOVE_DIALOG_CANCEL_BUTTON_LABEL
                    },
                    null);

    if (option == JOptionPane.OK_OPTION) {
        setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());

        return true;
    }

    return false;
}
 
Example 8
Source File: PruebaCorrelacionIdiomas.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Genera el texto aleatorio, sacando una ventana para preguntar el idioma en el que
 * se quiere el texto entre los disponibles.
 *
 */
   protected void generaTexto() {
   	Enumeration<String> claves = idiomasCargados.keys();
   	String [] idiomas = new String [idiomasCargados.size()];
   	for (int i=0;i<idiomas.length;i++)
   	{
   		idiomas[i] = claves.nextElement();
   	}
   	int seleccionado = JOptionPane.showOptionDialog(
   			SwingUtilities.getWindowAncestor(this),
   			"Selecciona en qué idioma genero el texto",
   			"Selección de idioma",
   			JOptionPane.DEFAULT_OPTION,
   			JOptionPane.QUESTION_MESSAGE,
   			null,
   			idiomas,
   			0
   			);
   	
   	if(seleccionado <0)
   		return;
   	
   	GeneradorTexto generador = new GeneradorTexto(
   			idiomas[seleccionado],
   			new InputStreamReader (
   					getClass().getClassLoader().getResourceAsStream(
   							idiomasCargados.get(idiomas[seleccionado]))));
   	StringBuffer textoGenerado = generador.dameTexto(500);
   	areaDeTextoAAnalizar.setText("");
   	areaDeTextoAAnalizar.setText(textoGenerado.toString());
}
 
Example 9
Source File: ExceptionSafePlugin.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void showExceptionDialog(Exception e) {
    Object[] buttonTexts = {
        Messages.PLUGIN_EXCEPTION_DIALOG_BUTTON_OK,
        Messages.PLUGIN_EXCEPTION_DIALOG_BUTTON_EXIT,
        Messages.PLUGIN_EXCEPTION_DIALOG_BUTTON_IGNORE
    };

    String message = String.format(
        Messages.PLUGIN_EXCEPTION_DIALOG_MESSAGE,
        plugin.getClass().getSimpleName(),
        String.valueOf(e.getMessage())
    );

    int buttonIndex = JOptionPane.showOptionDialog(
        null,
        message,
        Messages.PLUGIN_EXCEPTION_DIALOG_TITLE,
        JOptionPane.YES_NO_CANCEL_OPTION,
        JOptionPane.ERROR_MESSAGE,
        null,
        buttonTexts,
        buttonTexts[0]
    );

    if (buttonIndex == 1) {
        System.exit(0);
    }
    ignoreExceptions = buttonIndex == 2;
}
 
Example 10
Source File: Dialogs3.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
public static void main(String [] args){
// declara-se as opções
Object[] options = { "OK", "CANCELAR", "VOLTAR" };
// chama-se o OptionDialog
      JOptionPane.showOptionDialog(null, "Clique OK para continuar", "Aviso", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
System.exit(0);
  }
 
Example 11
Source File: TCPConnection.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean promptYesNo(String message) {
	Object[] options = { "yes", "no" };
	int foo = JOptionPane.showOptionDialog(null, 
			message, 
			"Warning", 
			JOptionPane.DEFAULT_OPTION,
			JOptionPane.WARNING_MESSAGE, 
			null, options, options[0]);
	return foo == 0;
}
 
Example 12
Source File: Test.java    From xunxian with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	Object[] options = {"在线购买","联系客服购买","取消"};
	int response=JOptionPane.showOptionDialog(null, "这是个选项对话框,用户可以选择自己的按钮的个数", "选项对话框标题",JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
	System.out.println(response);
}
 
Example 13
Source File: J2DBench.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean saveResults(String title, String desc) {
    lastResults.setTitle(title);
    lastResults.setDescription(desc);
    JFileChooser fc = getFileChooser();
    int ret = fc.showSaveDialog(guiFrame);
    if (ret == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        boolean append = false;
        if (file.exists()) {
            if (!file.isFile()) {
                System.err.println("Cannot save results to a directory!");
                return false;
            }
            ret = JOptionPane.showOptionDialog
                (guiFrame,
                 new String[] {
                     "The file '"+file.getName()+"' already exists!",
                     "",
                     "Do you wish to overwrite or append to this file?",
                 },
                 "File exists!",
                 JOptionPane.DEFAULT_OPTION,
                 JOptionPane.WARNING_MESSAGE,
                 null, new String[] {
                     "Overwrite",
                     "Append",
                     "Cancel",
                 }, "Cancel");
            if (ret == 0) {
                append = false;
            } else if (ret == 1) {
                append = true;
            } else {
                return false;
            }
        }
        String reason = saveResults(file, append);
        if (reason == null) {
            return true;
        } else {
            System.err.println(reason);
        }
    }
    return false;
}
 
Example 14
Source File: PlacePanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void territorySelected(final Territory territory, final MouseDetails e) {
  if (!isActive() || (e.getButton() != MouseEvent.BUTTON1)) {
    return;
  }
  final PlaceableUnits placeableUnits = getUnitsToPlace(territory);
  final Collection<Unit> units = placeableUnits.getUnits();
  final int maxUnits = placeableUnits.getMaxUnits();
  if (units.isEmpty()) {
    return;
  }
  final UnitChooser chooser =
      new UnitChooser(units, Map.of(), false, getMap().getUiContext());
  final String messageText = "Place units in " + territory.getName();
  if (maxUnits >= 0) {
    chooser.setMaxAndShowMaxButton(maxUnits);
  }
  final Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize();
  final int availHeight = screenResolution.height - 120;
  final int availWidth = screenResolution.width - 40;
  final JScrollPane scroll = new JScrollPane(chooser);
  scroll.setBorder(BorderFactory.createEmptyBorder());
  scroll.setPreferredSize(
      new Dimension(
          (scroll.getPreferredSize().width > availWidth
              ? availWidth
              : (scroll.getPreferredSize().width
                  + (scroll.getPreferredSize().height > availHeight ? 20 : 0))),
          (scroll.getPreferredSize().height > availHeight
              ? availHeight
              : (scroll.getPreferredSize().height
                  + (scroll.getPreferredSize().width > availWidth ? 26 : 0)))));
  final int option =
      JOptionPane.showOptionDialog(
          getTopLevelAncestor(),
          scroll,
          messageText,
          JOptionPane.OK_CANCEL_OPTION,
          JOptionPane.PLAIN_MESSAGE,
          null,
          null,
          null);
  if (option == JOptionPane.OK_OPTION) {
    final Collection<Unit> choosen = chooser.getSelected();
    placeData = new PlaceData(choosen, territory);
    updateUnits();
    if (choosen.containsAll(units)) {
      leftToPlaceLabel.setText("");
    }
    release();
  }
}
 
Example 15
Source File: SketchFrame.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Sets up the frame to allow data manipulation of a db defined by the current
 * sketch layout. If we can't get a connection, or the user cannot confirm that
 * the sketch indeed represents the db, we do nothing.
 */
public void enableDataManip(boolean show) {
	final String lineSep = EasikTools.systemLineSeparator();

	if (!getMModel().getDatabase().hasConnection()) {
		String type;
		if (!getMModel().getConnectionParams().containsKey("type")) {
			type = getMModel().getDatabaseType(); // start by getting the
			// database type
		} else {
			type = getMModel().getConnectionParams().get("type");
		}

		if (type == null) {
			return;
		}

		final DatabaseOptions dbopts = new DatabaseOptions(type, getMModel().getFrame());

		if (!dbopts.isAccepted()) {
			return;
		}

		// set the database access object up for database exporting
		if (!getMModel().getDatabase().setDatabaseExport(type, dbopts.getParams())) {
			_ourSketch.getDatabase().cleanDatabaseDriver();

			return;
		}

		if (!getMModel().getDatabase().hasActiveDriver()) {
			_ourSketch.getDatabase().cleanDatabaseDriver(); // should have
															// been loaded
															// by now
			return;
		}

		getMModel().getDatabase().getJDBCConnection();

	}

	if (!_ourSketch.getDatabase().hasActiveDriver()) {
		_ourSketch.getDatabase().cleanDatabaseDriver();
		JOptionPane.showMessageDialog(this,
				"This Sketch does not have an outgoing connection.\nYou must connect through 'Export to DBMS' menu option...",
				"Manipulate db...", JOptionPane.INFORMATION_MESSAGE);

		return;
	}

	if (!_ourSketch.isSynced()) {
		final String[] choices = { "Yes", "Cancel" };
		final int choice = JOptionPane.showOptionDialog(this,
				"It appears that this sketch has either not been exported to the db," + lineSep
						+ "or modifications have been made since an export." + lineSep
						+ "Are you sure that the db is accurately represented by this sketch?",
				"Confirm Connection", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, choices,
				choices[0]);

		if (choice != 0) {
			_ourSketch.getDatabase().cleanDatabaseDriver();

			return;
		}
	}

	_ourSketch.setSynced(true);

	// enable menus and menu items that may have been dissabled if we have
	// been in data manip mode
	_AddCommutativeDiagramMenuItem.setEnabled(false);
	_AddSumMenuItem.setEnabled(false);
	_AddProductMenuItem.setEnabled(false);
	_AddPullbackMenuItem.setEnabled(false);
	_AddEqualizerMenuItem.setEnabled(false);
	// _AddLimMenuItem.setEnabled(false);
	menuEditEdit.setVisible(false);
	menuConstraint.setVisible(false);
	menuEditManip.setVisible(true);
	menuSQL.setVisible(true);

	_mode = Mode.MANIPULATE;

	setEasikTitle();
	if (show) {
		setVisible(true);
	}
	_ourSketch.refresh();
}
 
Example 16
Source File: SwingClientApplication.java    From chipster with MIT License 4 votes vote down vote up
@Override
public void setVisualisationMethod(VisualisationMethod method, List<Variable> variables, List<DataBean> datas, FrameType target) {
	
	if (method == null) {
		boolean datasetsSelected = (datas != null && !datas.isEmpty());
		boolean datasetsExist = !getDataManager().databeans().isEmpty();
		
		if (datasetsSelected) {
			method = VisualisationMethods.DATA_DETAILS;
		} else if (datasetsExist) {
			method = VisualisationMethods.SESSION_DETAILS;
		} else {				
			method = VisualisationMethods.EMPTY;
		}				
		
		super.setVisualisationMethod(method, variables, datas, target);
		return;
	}

	long estimate = method.estimateDuration(datas);

	if (estimate > SLOW_VISUALISATION_LIMIT) {
		int returnValue = JOptionPane.DEFAULT_OPTION;

		String message = "";
		int severity;
		// Check the running tasks
		if (estimate > VERY_SLOW_VISUALISATION_LIMIT) {

			message += "Visualising the selected large dataset with this method might stop Chipster from responding. \n" + "If you choose to continue, it's recommended to save the session before visualising.";
			severity = JOptionPane.WARNING_MESSAGE;
		} else {
			message += "Are you sure you want to visualise large dataset, which may " + "take several seconds?";
			severity = JOptionPane.QUESTION_MESSAGE;
		}
		Object[] options = { "Cancel", "Visualise" };

		returnValue = JOptionPane.showOptionDialog(this.getMainFrame(), message, "Cancel visualisation", JOptionPane.YES_NO_OPTION, severity, null, options, options[0]);

		if (returnValue == 1) {
			super.setVisualisationMethod(method, variables, datas, target);
		} else {
			return;
		}
	} else {
		super.setVisualisationMethod(method, variables, datas, target);
	}
}
 
Example 17
Source File: GillespieSSAJavaSingleStep.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
public String[] openEventInteractiveMenu(ArrayList<EventQueueElement> eventReadyArray) {
	String[] CustomParamsEventMenu=new String[2];
	JPanel nextEventsPanel = new JPanel();
	JPanel nextEventFireTimePanel = new JPanel();
	JPanel mainPanel = new JPanel(new BorderLayout());
	nextEventsPanel.add(new JLabel("Next event to fire:"));
	// create a drop-down list of next possible firing events
	int sizeEventReadyArray = eventReadyArray.size();
	String[] nextEventsArray = new String[sizeEventReadyArray];
	Random generator = new Random();
	int eventToFireIndex = generator.nextInt(sizeEventReadyArray);
	nextEventsArray[0] = eventReadyArray.get(eventToFireIndex).getEventId();
	EventQueueElement eventToFire = eventReadyArray.remove(eventToFireIndex);	
	for (int i=1; i<sizeEventReadyArray; i++) {
		nextEventsArray[i] = eventReadyArray.get(i-1).getEventId();
	}
	eventReadyArray.add(eventToFireIndex, eventToFire);
	nextEventsList = new JComboBox(nextEventsArray);
	nextEventsPanel.add(nextEventsList);
	mainPanel.add(nextEventsPanel, "Center");
	Object[] options = {"OK", "Cancel", "Terminate"};
	Object[] singleOpt = {"OK"};
	int optionValue;
	// optionValue: 0=OK, 1=Cancel, 2=Terminate
	optionValue = JOptionPane.showOptionDialog(Gui.frame, mainPanel, "Next Event Selection",
	JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
	CustomParamsEventMenu[0] = optionValue + "";
	String eventSelected = (String)nextEventsList.getSelectedItem();
	if (eventSelected.equals(eventToFire.getEventId())) { // user selected event is the same as the randomly selected one.
		nextEventFireTimePanel.add(new JLabel("The selected event will fire at time " + eventToFire.getScheduledTime() + "."));
		JOptionPane.showOptionDialog(Gui.frame, nextEventFireTimePanel, "Next Event Selection",
				JOptionPane.YES_OPTION, JOptionPane.PLAIN_MESSAGE, null, singleOpt, singleOpt[0]);
		CustomParamsEventMenu[1] = "" + eventReadyArray.indexOf(eventToFire);
		return CustomParamsEventMenu;
	}
	int eventSelectedIndex = -1;
	double eventSelectedScheduledTime = -1;
	for (int i = 0; i<sizeEventReadyArray; i++) {
		if (eventReadyArray.get(i).getEventId() == eventSelected) {
			eventSelectedIndex = i;
			eventSelectedScheduledTime = eventReadyArray.get(i).getScheduledTime();
			break;
		}
	}
	nextEventFireTimePanel.add(new JLabel("The selected event will fire at some time " + eventSelectedScheduledTime + "."));
	JOptionPane.showOptionDialog(Gui.frame, nextEventFireTimePanel, "Next Event Selection",
			JOptionPane.YES_OPTION, JOptionPane.PLAIN_MESSAGE, null, singleOpt, singleOpt[0]);
	CustomParamsEventMenu[1] = "" + eventSelectedIndex;
	return CustomParamsEventMenu;
}
 
Example 18
Source File: AnalysisView.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
private void addAbstractionMethod(ActionEvent e)
{
  JPanel addAbsPanel = new JPanel(new BorderLayout());
  JComboBox<String> absList = new JComboBox<String>();
  if (e.getSource() == addPreAbs)
  {
    absList.addItem("complex-formation-and-sequestering-abstraction");
  }
  absList.addItem("operator-site-reduction-abstraction");
  absList.addItem("absolute-activation/inhibition-generator");
  absList.addItem("absolute-inhibition-generator");
  absList.addItem("birth-death-generator");
  absList.addItem("birth-death-generator2");
  absList.addItem("birth-death-generator3");
  absList.addItem("birth-death-generator4");
  absList.addItem("birth-death-generator5");
  absList.addItem("birth-death-generator6");
  absList.addItem("birth-death-generator7");
  absList.addItem("degradation-stoichiometry-amplifier");
  absList.addItem("degradation-stoichiometry-amplifier2");
  absList.addItem("degradation-stoichiometry-amplifier3");
  absList.addItem("degradation-stoichiometry-amplifier4");
  absList.addItem("degradation-stoichiometry-amplifier5");
  absList.addItem("degradation-stoichiometry-amplifier6");
  absList.addItem("degradation-stoichiometry-amplifier7");
  absList.addItem("degradation-stoichiometry-amplifier8");
  absList.addItem("dimer-to-monomer-substitutor");
  absList.addItem("dimerization-reduction");
  absList.addItem("dimerization-reduction-level-assignment");
  absList.addItem("distribute-transformer");
  absList.addItem("enzyme-kinetic-qssa-1");
  absList.addItem("enzyme-kinetic-rapid-equilibrium-1");
  absList.addItem("enzyme-kinetic-rapid-equilibrium-2");
  absList.addItem("final-state-generator");
  absList.addItem("inducer-structure-transformer");
  absList.addItem("irrelevant-species-remover");
  absList.addItem("kinetic-law-constants-simplifier");
  absList.addItem("max-concentration-reaction-adder");
  absList.addItem("modifier-constant-propagation");
  absList.addItem("modifier-structure-transformer");
  absList.addItem("multiple-products-reaction-eliminator");
  absList.addItem("multiple-reactants-reaction-eliminator");
  absList.addItem("nary-order-unary-transformer");
  absList.addItem("nary-order-unary-transformer2");
  absList.addItem("nary-order-unary-transformer3");
  absList.addItem("operator-site-forward-binding-remover");
  absList.addItem("operator-site-forward-binding-remover2");
  absList.addItem("pow-kinetic-law-transformer");
  absList.addItem("ppta");
  absList.addItem("reversible-reaction-structure-transformer");
  absList.addItem("reversible-to-irreversible-transformer");
  absList.addItem("similar-reaction-combiner");
  absList.addItem("single-reactant-product-reaction-eliminator");
  absList.addItem("stoichiometry-amplifier");
  absList.addItem("stoichiometry-amplifier2");
  absList.addItem("stoichiometry-amplifier3");
  absList.addItem("stop-flag-generator");
  addAbsPanel.add(absList, "Center");
  String[] options = { "Add", "Cancel" };
  int value = JOptionPane.showOptionDialog(Gui.frame, addAbsPanel, "Add abstraction method", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
  if (value == JOptionPane.YES_OPTION)
  {
    if (e.getSource() == addPreAbs)
    {
      Utility.add(preAbs, absList.getSelectedItem());
    }
    else if (e.getSource() == addLoopAbs)
    {
      Utility.add(loopAbs, absList.getSelectedItem());
    }
    else
    {
      Utility.add(postAbs, absList.getSelectedItem());
    }
  }
}
 
Example 19
Source File: J2DBench.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static boolean saveResults(String title, String desc) {
    lastResults.setTitle(title);
    lastResults.setDescription(desc);
    JFileChooser fc = getFileChooser();
    int ret = fc.showSaveDialog(guiFrame);
    if (ret == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        boolean append = false;
        if (file.exists()) {
            if (!file.isFile()) {
                System.err.println("Cannot save results to a directory!");
                return false;
            }
            ret = JOptionPane.showOptionDialog
                (guiFrame,
                 new String[] {
                     "The file '"+file.getName()+"' already exists!",
                     "",
                     "Do you wish to overwrite or append to this file?",
                 },
                 "File exists!",
                 JOptionPane.DEFAULT_OPTION,
                 JOptionPane.WARNING_MESSAGE,
                 null, new String[] {
                     "Overwrite",
                     "Append",
                     "Cancel",
                 }, "Cancel");
            if (ret == 0) {
                append = false;
            } else if (ret == 1) {
                append = true;
            } else {
                return false;
            }
        }
        String reason = saveResults(file, append);
        if (reason == null) {
            return true;
        } else {
            System.err.println(reason);
        }
    }
    return false;
}
 
Example 20
Source File: SendEMailDialog.java    From tn5250j with GNU General Public License v2.0 4 votes vote down vote up
/**
	 * Constructor to send a file
	 *
	 * @param parent
	 * @param session
	 */
	public SendEMailDialog(Frame parent, SessionPanel session, String fileName) {

		if (!isEMailAvailable()) {

			JOptionPane.showMessageDialog(
				parent,
				LangTool.getString("messages.noEmailAPI"),
				"Error",
				JOptionPane.ERROR_MESSAGE,
				null);
		}
		else {

			this.session = session;

			Object[] message = new Object[1];
			message[0] = setupMailPanel(fileName);
			String[] options = new String[3];

			int result = 0;
			while (result == 0 || result == 2) {

				// setup the dialog options
				setOptions(options);
				result = JOptionPane.showOptionDialog(parent,
				// the parent that the dialog blocks
				message, // the dialog message array
				LangTool.getString("em.titleFileTransfer"),
				// the title of the dialog window
				JOptionPane.DEFAULT_OPTION, // option type
				JOptionPane.PLAIN_MESSAGE, // message type
				null, // optional icon, use null to use the default icon
				options, // options string array, will be made into buttons//
				options[0] // option that should be made into a default button
			);

				switch (result) {
					case 0 : // Send it

                  sendEMail = new SendEMail();

						sendEMail.setConfigFile("SMTPProperties.cfg");
						sendEMail.setTo((String) toAddress.getSelectedItem());
						sendEMail.setSubject(subject.getText());
						if (bodyText.getText().length() > 0)
							sendEMail.setMessage(bodyText.getText());

						if (attachmentName.getText().length() > 0)
							sendEMail.setAttachmentName(attachmentName.getText());

						if (fileName != null && fileName.length() > 0)
							sendEMail.setFileName(fileName);

						// send the information
						sendIt(parent, sendEMail);

//						sendEMail.release();
//						sendEMail = null;

						break;
					case 1 : // Cancel
						//		      System.out.println("Cancel");
						break;
					case 2 : // Configure SMTP
						configureSMTP(parent);
						//		      System.out.println("Cancel");
						break;
					default :
						break;
				}
			}
		}
	}