Java Code Examples for javax.swing.JOptionPane

The following examples show how to use javax.swing.JOptionPane. These examples are extracted from open source projects.
Example 1
Project: ramus   File: DemoChecker.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void elementCreated(ElementEvent event) {
    IEngineImpl impl = (IEngineImpl) event.getEngine().getDeligate();
    String prefix = impl.getPrefix();
    long elementCount = getElementCount(impl, prefix);
    if (elementCount > 100) {
        framework.propertyChanged("DisableSaveActions");
    }
    if ((elementCount == 101) && (framework.get("FilePlugin") != null)) {

        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                JOptionPane.showMessageDialog(framework.getMainFrame(),
                        MessageFormat.format(GlobalResourcesManager
                                        .getString("DemoVersionElementCountLimit"),
                                100));
            }
        });
    }

}
 
Example 2
Project: djl-demo   File: ViewerFrame.java    License: Apache License 2.0 6 votes vote down vote up
ViewerFrame(int width, int height) {
    frame = new JFrame("Demo");
    imagePanel = new ImagePanel();
    frame.setLayout(new BorderLayout());
    frame.add(BorderLayout.CENTER, imagePanel);

    JOptionPane.setRootFrame(frame);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    if (width > screenSize.width) {
        width = screenSize.width;
    }
    Dimension frameSize = new Dimension(width, height);
    frame.setSize(frameSize);
    frame.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 3
Project: WorldPainter   File: SimpleBrowser.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void jEditorPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jEditorPane1HyperlinkUpdate
    if (evt.getEventType() == EventType.ACTIVATED) {
        URL url = evt.getURL();
        try {
            jEditorPane1.setPage(url);
            if (historyPointer == (historySize - 1)) {
                // At the end of the history
                history.add(url.toExternalForm());
                historyPointer++;
                historySize++;
            } else {
                // Not at the end of the history; erase the tail end
                historyPointer++;
                history.set(historyPointer, url.toExternalForm());
                historySize = historyPointer + 1;
            }
            backAction.setEnabled(true);
            forwardAction.setEnabled(false);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(this, "I/O error loading page " + url, "Error Loading Page", JOptionPane.ERROR_MESSAGE);
        }
    }
}
 
Example 4
Project: ChatGameFontificator   File: FontificatorProperties.java    License: The Unlicense 6 votes vote down vote up
/**
 * Called whenever unsaved changes might be lost to let the user have the option to save them
 * 
 * @param ctrlWindow
 * @return okayToContinue
 */
public boolean checkForUnsavedProps(ControlWindow ctrlWindow, Component parent)
{
    if (hasUnsavedChanges())
    {
        int response = JOptionPane.showConfirmDialog(parent, "Save configuration changes?", "Unsaved Changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION)
        {
            if (ctrlWindow.saveConfig())
            {
                return true;
            }
        }
        else if (response == JOptionPane.NO_OPTION)
        {
            return true;
        }

        return false;
    }
    else
    {
        return true;
    }
}
 
Example 5
Project: iBioSim   File: LearnView.java    License: Apache License 2.0 6 votes vote down vote up
public void updateSpecies(String newLearnFile)
{
  learnFile = newLearnFile;

  try 
  {
    speciesList = Learn.writeBackgroundFile(learnFile, directory);
  } 
  catch (XMLStreamException | IOException | BioSimException e) 
  {
    JOptionPane.showMessageDialog(Gui.frame, "Unable to create background file!", "Error Writing Background", JOptionPane.ERROR_MESSAGE);
    speciesList = new ArrayList<String>();
  }
  if (user.isSelected())
  {
    auto.doClick();
    user.doClick();
  }
  else
  {
    user.doClick();
    auto.doClick();
  }
}
 
Example 6
Project: JAVA-MVC-Swing-Monopoly   File: Control.java    License: 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 7
Project: BotLibre   File: BotFrame.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void actionPerformed(ActionEvent event) {
	String database = (String)JOptionPane.showInputDialog(
			BotFrame.this,
		"Enter database name to import:",
		"Import Dialog",
		JOptionPane.PLAIN_MESSAGE,
		null,
		null,
		"");
	if (database == null) {
		return;
	}
	try {
		getBot().memory().importMemory(database);
	} catch (Exception failed) {
		failed.printStackTrace();
		JOptionPane.showMessageDialog(BotFrame.this,
			failed.toString(),
			"Import failed",
			JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 8
Project: pcgen   File: PCGenFrame.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Revert the character to the previous save. If no previous save, open a
 * new character tab.
 * @param character The character being saved.
 */
public void revertCharacter(CharacterFacade character)
{
	if (character.isDirty())
	{
		int ret =
				JOptionPane.showConfirmDialog(this,
					LanguageBundle.getFormattedString("in_revertPcChoice", character //$NON-NLS-1$
					.getNameRef().get()), Constants.APPLICATION_NAME, JOptionPane.YES_NO_OPTION);
		if (ret == JOptionPane.YES_OPTION)
		{
			CharacterManager.removeCharacter(character);

			if (character.getFileRef().get() != null && character.getFileRef().get().exists())
			{
				openCharacter(character.getFileRef().get(), currentDataSetRef.get());
			}
			else
			{
				createNewCharacter(null);
			}
		}
	}

}
 
Example 9
Project: ramus   File: ReadedModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object,
 * int, int)
 */
public void setValueAt(final Object arg0, final int y, final int x) {
    final String s = (String) arg0;
    final Readed r = readeds.get(y);
    if (x == 0)
        r.setReader(s);
    else {
        final String oldd = r.getDate();
        try {
            r.setDate(s);
        } catch (final ParseException e) {
            try {
                JOptionPane.showMessageDialog(null, s + " - "
                        + ResourceLoader.getString("not_a_date"));
                r.setDate(oldd);
            } catch (final ParseException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
Example 10
Project: openAGV   File: UserMessageHelper.java    License: Apache License 2.0 6 votes vote down vote up
private int translateType(Type type) {
  int jOptionType;
  switch (type) {
    case ERROR:
      jOptionType = JOptionPane.ERROR_MESSAGE;
      break;
    case INFO:
      jOptionType = JOptionPane.INFORMATION_MESSAGE;
      break;
    case QUESTION:
      jOptionType = JOptionPane.YES_NO_OPTION;
      break;
    default:
      jOptionType = JOptionPane.PLAIN_MESSAGE;
  }
  return jOptionType;
}
 
Example 11
Project: Websocket-Smart-Card-Signer   File: SignUI.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public void sign(CertificateData certData, String pin){
    if(signEngine.getNumDataToSign() == 0){
        SignUtils.playBeeps(2);
        JOptionPane.showMessageDialog(null, "NO DATA TO SIGN", "ERROR", JOptionPane.ERROR_MESSAGE);
        return;
    }
 
    try {
        signEngine.sign(certData, pin);
    } catch (Exception e) {
        e.printStackTrace();
        SignUtils.playBeeps(1);
        JOptionPane.showMessageDialog(null, "ERROR DURING THE SIGNING PROCESS:\n"+e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
    }
}
 
Example 12
Project: dctb-utfpr-2018-1   File: GerenciadorDeContaInterface.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	
	Integer opcao = lerOpcaoDoMenu();
	
	while(opcao != SAIR_DO_PROGRAMA){
		switch(opcao){
		case CRIAR_CONTA:
			criarNovaConta();
			break;
		case CONSULTA_SALDO:
			consultarSaldo();
			break;
		case CONSULTA_AGENCIA:
			consultarAgencia();
			break;
		case ALTERAR_TITULAR:
			alterarNomeDoTitular();
			break;
		case REMOVER_CONTA:
			removerConta();
			break;
		case LISTAR_CONTAS:
			listarContas();
			break;
		case SAIR_DO_PROGRAMA:
			JOptionPane.showMessageDialog(null,"[Programa será encerado!]");
			break;
		 default:
			 JOptionPane.showMessageDialog(null,"Opcao Invalida!");
			 break;
		}
		
		opcao = lerOpcaoDoMenu();
	}
	
}
 
Example 13
Project: knopflerfish.org   File: JPrefsPanel.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void doAddKey() {
  try {
    String name = JOptionPane.showInputDialog(this, 
                                              "New key name",
                                              "New key...",
                                              JOptionPane.YES_NO_OPTION);
    if(name != null && !"".equals(name)) {  
      node.put(name, node.get(name, ""));
      node.flush();
    }
    setPreferences(node);
  } catch (Exception e) {
    Activator.log.warn("Failed to add key", e);
  }
}
 
Example 14
Project: HackBar   File: Methods.java    License: MIT License 5 votes vote down vote up
public static String prompt_and_validate_input(String prompt, String str){
    String user_input = JOptionPane.showInputDialog(prompt, str);
    while(user_input.trim().equals("")){
        user_input = JOptionPane.showInputDialog(prompt, str);
    }
    return user_input.trim();
}
 
Example 15
Project: magarena   File: DuelDecksScreen.java    License: GNU General Public License v3.0 5 votes vote down vote up
private boolean confirmPlayWithInvalidDecks() {
    final String message = String.format("<html><b>%s</b><br><br>%s</html>",
        MText.get(_S15), MText.get(_S16)
    );
    final Object[] params = {message};
    final int n = JOptionPane.showConfirmDialog(screenContent,
        params,
        MText.get(_S17),
        JOptionPane.YES_NO_OPTION);
    return n == JOptionPane.YES_OPTION;
}
 
Example 16
Project: Pydev   File: GraphView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void createImage(String imageName) {
    if (graph == null) {
        return;
    }
    try {
        ImageWriter writer;
        writer = new ImageWriter(graph.getImage(null, GraphConstants.DEFAULTINSET), imageName);

        SwingUtilities.invokeLater(writer);
    } catch (Throwable e) {
        JOptionPane msgbox = new JOptionPane("Error writing file: " + e.getMessage());
        msgbox.setVisible(true);
    }
}
 
Example 17
Project: rcrs-server   File: ScenarioEditor.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
   Set the map and scenario.
   @param newMap The new map.
   @param newScenario The new scenario.
   @throws CancelledByUserException If the user cancels the change due to unsaved changes.
*/
public void setScenario(GMLMap newMap, GisScenario newScenario) throws CancelledByUserException {
    checkForChanges();
    if (!checkScenario(newMap, newScenario)) {
        JOptionPane.showMessageDialog(null, "The scenario file contained errors.");
        return;
    }
    map = newMap;
    scenario = newScenario;
    changed = false;
    viewer.setMap(map);
    inspector.setMap(map);
    updateOverlays();
}
 
Example 18
Project: PolyGlot   File: InfoBox.java    License: MIT License 5 votes vote down vote up
/**
 * Displays confirmation of user action
 *
 * @param title title of query message
 * @param message shown to user
 * @param parent parent caller
 * @return true if chooser accepts, false otherwise
 */
public static boolean actionConfirmation(String title, String message, Window parent) {
    PButton[] buttons = {YES, NO};
    int option = POptionPane.internalShowOptionDialog(parent,
            message,
            title,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE,
            UIManager.getIcon("OptionPane.questionIcon"),
            buttons,
            null);

    return option == JOptionPane.YES_OPTION;
}
 
Example 19
Project: jeveassets   File: Program.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by macOsxCode() - should not be changed
 */
public void exit() {
	if (getStatusPanel().updateInProgress() > 0) {
		int value = JOptionPane.showConfirmDialog(getMainWindow().getFrame(),  GuiFrame.get().exitMsg(getStatusPanel().updateInProgress()), GuiFrame.get().exitTitle(getStatusPanel().updateInProgress()), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
		if (value != JOptionPane.OK_OPTION) {
			return;
		}
	}
	getStatusPanel().cancelUpdates();
	saveExit();
	LOG.info("Running shutdown hook(s) and exiting...");
	System.exit(0);
}
 
Example 20
Project: GpsPrune   File: RemoveAudioFunction.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Perform the function
 */
public void begin()
{
	// Delete the current audio, and optionally its point too, keeping undo information
	AudioClip currentAudio = _app.getTrackInfo().getCurrentAudio();
	if (currentAudio != null)
	{
		// Audio is selected, see if it has a point or not
		boolean deleted = false;
		UndoDeleteAudio undoAction = null;
		if (currentAudio.getDataPoint() == null)
		{
			// no point attached, so just delete
			undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(),
				null, -1);
			deleted = _app.getTrackInfo().deleteCurrentAudio(false);
		}
		else
		{
			// point is attached, so need to confirm point deletion
			final int pointIndex = _app.getTrackInfo().getTrack().getPointIndex(currentAudio.getDataPoint());
			undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(),
				currentAudio.getDataPoint(), pointIndex);
			undoAction.setAtBoundaryOfSelectedRange(pointIndex == _app.getTrackInfo().getSelection().getStart() ||
				pointIndex == _app.getTrackInfo().getSelection().getEnd());
			int response = JOptionPane.showConfirmDialog(_app.getFrame(),
				I18nManager.getText("dialog.deleteaudio.deletepoint"),
				I18nManager.getText(getNameKey()), JOptionPane.YES_NO_CANCEL_OPTION);
			boolean deletePointToo = (response == JOptionPane.YES_OPTION);
			// Cancel delete if cancel pressed or dialog closed
			if (response == JOptionPane.YES_OPTION || response == JOptionPane.NO_OPTION) {
				deleted = _app.getTrackInfo().deleteCurrentAudio(deletePointToo);
			}
		}
		// Add undo information to stack if necessary
		if (deleted) {
			_app.completeFunction(undoAction, currentAudio.getName() + " " + I18nManager.getText("confirm.media.removed"));
		}
	}
}
 
Example 21
Project: jdal   File: ViewCancelAction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void actionPerformed(ActionEvent e) {
	if (getView().isDirty()) {
		if (JOptionPane.YES_OPTION == 
				JOptionPane.showConfirmDialog(getView().getPanel(), 
						getMessageWrapper().getMessage("ViewCancelAction.dirty"))) {
		
			getDialog().dispose();
		}
	}
	else {
		getDialog().dispose();
	}
}
 
Example 22
Project: pcgen   File: Main.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Check that the runtime environment is suitable for PCGen to run.
 */
private static void validateEnvironment(boolean useGui)
{
	// Check our main folders are present
	String[] neededDirs = {ConfigurationSettings.getSystemsDir(), ConfigurationSettings.getPccFilesDir(),
		ConfigurationSettings.getPluginsDir(), ConfigurationSettings.getPreviewDir(),
		ConfigurationSettings.getOutputSheetsDir()};
	StringBuilder missingDirs = new StringBuilder();
	for (final String dirPath : neededDirs)
	{
		File dir = new File(dirPath);
		if (!dir.exists())
		{
			String path = dirPath;
			try
			{
				path = dir.getCanonicalPath();
			}
			catch (IOException e)
			{
				Logging.errorPrint("Unable to find canonical path for " + dir);
			}
			missingDirs.append("  ").append(path).append('\n');
		}
	}
	if (missingDirs.length() > 0)
	{
		String message;
		message = "This installation of PCGen is missing the following required folders:\n" + missingDirs;
		Logging.errorPrint(message);
		if (useGui)
		{
			JOptionPane.showMessageDialog(null, message + "\nPlease reinstall PCGen.", Constants.APPLICATION_NAME,
				JOptionPane.ERROR_MESSAGE);
		}
		System.exit(1);
	}
}
 
Example 23
Project: jeveassets   File: LoadoutsTab.java    License: GNU General Public License v2.0 5 votes vote down vote up
private String getBuildName() {
	String buildName = JOptionInput.showInputDialog(program.getMainWindow().getFrame(), "Enter Build Name", "Export EFT", JOptionPane.PLAIN_MESSAGE);
	if (buildName == null) {
		return null; //Cancel
	} else if (buildName.isEmpty()) {
		JOptionPane.showMessageDialog(program.getMainWindow().getFrame(),
				TabsLoadout.get().name1(),
				TabsLoadout.get().empty(),
				JOptionPane.PLAIN_MESSAGE);
		return getBuildName();
	} else {
		return buildName;
	}
}
 
Example 24
Project: pgptool   File: EncryptOnePm.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void notifyUserOfMissingKeysIfAny(Set<String> missedKeys, PropertyChangeEvent evt) {
	if (CollectionUtils.isEmpty(missedKeys)) {
		return;
	}

	UiUtils.messageBox(UiUtils.actionEvent(evt),
			text("error.notAllRecipientsAvailable", Arrays.asList(missedKeys)), text("term.attention"),
			JOptionPane.WARNING_MESSAGE);
}
 
Example 25
Project: pcgen   File: PCGenActionMap.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e)
{
	try
	{
		DesktopBrowserLauncher.viewInBrowser(new File(ConfigurationSettings.getDocsDir(), "index.html"));
	}
	catch (IOException ex)
	{
		Logging.errorPrint("Could not open docs in external browser", ex);
		JOptionPane.showMessageDialog(frame, LanguageBundle.getString("in_menuDocsNotOpenMsg"),
			LanguageBundle.getString("in_menuDocsNotOpenTitle"), JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 26
Project: beast-mcmc   File: Utils.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void showExceptionDialog(Thread t, Throwable e,
		String message) {

	String msg = String.format("Unexpected problem on thread %s: %s" + "\n"
			+ message, t.getName(), e.getMessage());

	logException(t, e);

	JOptionPane.showMessageDialog(Utils.getActiveFrame(), //
			msg, //
			"Error", //
			JOptionPane.ERROR_MESSAGE, //
			Utils.createImageIcon(Utils.ERROR_ICON));
}
 
Example 27
Project: JavaMainRepo   File: BirdController.java    License: Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	// new AddController(new AddFrame("Hummingbird"), true);

	String choice = JOptionPane.showInputDialog("Load animal or enter info? (load/enter)");

	if (choice.equals("load")) {
		Animal animal = null;
		try {
			animal = speciesFactory.getAnimal(Constants.Animals.Birds.Hummingbird);
		} catch (Exception e2) {
			e2.printStackTrace();
		}
		animalList.add(animal);
		try {
			animalRepo.save(animalList);
		} catch (FileNotFoundException | XMLStreamException e1) {
			e1.printStackTrace();
		}
	} else if (choice.equals("enter")) {
		new AddController(new AddFrame("Hummingbird"), true);
		/*
		 * 
		 */

	} else {
		JOptionPane.showMessageDialog(frame, "Invalid choice.", "Warning", JOptionPane.WARNING_MESSAGE);
	}
}
 
Example 28
Project: portecle   File: DGenerateKeyPair.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate the key size value the user has entered as a string and convert it to an integer. Validate the key size
 * is supported for the particular key pair generation algorithm they have chosen.
 *
 * @return The Validity value or BAD_KEYSIZE if it is not valid
 */
private int validateKeySize()
{
	String sKeySize = m_jcbKeySize.getSelectedItem().toString();
	int iKeySize;

	if (sKeySize.isEmpty())
	{
		JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.KeySizeReq.message"), getTitle(),
		    JOptionPane.WARNING_MESSAGE);
		return BAD_KEYSIZE;
	}

	try
	{
		iKeySize = Integer.parseInt(sKeySize);
	}
	catch (NumberFormatException ex)
	{
		JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.KeySizeIntegerReq.message"), getTitle(),
		    JOptionPane.WARNING_MESSAGE);
		return BAD_KEYSIZE;
	}

	if (m_jrbDSA.isSelected() && (iKeySize < 512 || iKeySize % 64 != 0))
	{
		JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.UnsupportedDsaKeySize.message"),
		    getTitle(), JOptionPane.WARNING_MESSAGE);
		return BAD_KEYSIZE;
	}
	else if (iKeySize < 512)
	{
		JOptionPane.showMessageDialog(this, RB.getString("DGenerateKeyPair.UnsupportedRsaKeySize.message"),
		    getTitle(), JOptionPane.WARNING_MESSAGE);
		return BAD_KEYSIZE;
	}

	return iKeySize;
}
 
Example 29
Project: dctb-utfpr-2018-1   File: ManipulandoArquivo.java    License: Apache License 2.0 5 votes vote down vote up
private void mesagemUsuarioRecuperado(String recuperado) {
    JTextArea aux1 = new JTextArea(recuperado);
    JScrollPane aux = new JScrollPane(aux1){
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(250, 200);
        }
    };
    JOptionPane.showMessageDialog(null, aux, "Usuario Encontrado", JOptionPane.INFORMATION_MESSAGE);
}
 
Example 30
Project: dctb-utfpr-2018-1   File: Login.java    License: Apache License 2.0 5 votes vote down vote up
private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed
    if (!txtLogin.getText().isEmpty() && !txtPassword.getText().isEmpty()){
        this.dispose();
        new Home().setVisible(true);
    }  else{
        JOptionPane.showMessageDialog(null,"Digite login e senha");
    }      // TODO add your handling code here:
}
 
Example 31
Project: Hospital-Management   File: DocRec.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void Get_Data(){
  String sql="select DoctorID as 'Doctor ID', DoctorName as 'Doctor Name',FatherName as 'Father Name',Address,ContacNo as 'Contact No',Email as 'Email ID',Qualifications,Gender,BloodGroup as 'Blood Group',DateOfJoining as 'Joining Date' from Doctor order by DoctorName";        
  try{
     pst=con.prepareStatement(sql);
      rs= pst.executeQuery();
     jTable1.setModel(DbUtils.resultSetToTableModel(rs));
     }catch(Exception e){
        JOptionPane.showMessageDialog(null, e);
      
    }
}
 
Example 32
Project: swingsane   File: Misc.java    License: Apache License 2.0 5 votes vote down vote up
public static void showErrorMsg(final Component parent, final String message) {
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      JOptionPane.showMessageDialog(parent, message, Localizer.localize("ErrorMessageTitle"),
          JOptionPane.ERROR_MESSAGE);
    }
  });
}
 
Example 33
Project: jpexs-decompiler   File: MainPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
private MissingCharacterHandler getMissingCharacterHandler() {
    return new MissingCharacterHandler() {
        // "configuration items" for the current replace only
        private final ConfigurationItem<Boolean> showAgainIgnoreMissingCharacters = new ConfigurationItem<>("showAgainIgnoreMissingCharacters", true, true);

        private boolean ignoreMissingCharacters = false;

        @Override
        public boolean getIgnoreMissingCharacters() {
            return ignoreMissingCharacters;
        }

        @Override
        public boolean handle(TextTag textTag, final FontTag font, final char character) {
            String fontName = font.getSwf().sourceFontNamesMap.get(font.getFontId());
            if (fontName == null) {
                fontName = font.getFontName();
            }
            final Font f = FontTag.getInstalledFontsByName().get(fontName);
            if (f == null || !f.canDisplay(character)) {
                String msg = translate("error.font.nocharacter").replace("%char%", "" + character);
                logger.log(Level.SEVERE, "{0} FontId: {1} TextId: {2}", new Object[]{msg, font.getCharacterId(), textTag.getCharacterId()});
                ignoreMissingCharacters = View.showConfirmDialog(null, msg, translate("error"),
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE,
                        showAgainIgnoreMissingCharacters,
                        ignoreMissingCharacters ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION) == JOptionPane.OK_OPTION;
                return false;
            }

            font.addCharacter(character, f);

            return true;
        }
    };
}
 
Example 34
Project: MeteoInfo   File: FrmAttriData.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void jMenuItem_AddFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_AddFieldActionPerformed
    // TODO add your handling code here:
    FrmAddField frmField = new FrmAddField(null, true);
    frmField.setLocationRelativeTo(this);
    frmField.setVisible(true);
    if (frmField.isOK()) {
        String fieldName = frmField.getFieldName();
        if (fieldName.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Field name is empty!");
            return;
        }
        List<String> fieldNames = _layer.getFieldNames();
        if (fieldNames.contains(fieldName)) {
            JOptionPane.showMessageDialog(null, "Field name has exist in the data table!");
            return;
        }
        DataType dataType = frmField.getDataType();
        try {                
            _dataTable.addColumn(new Field(fieldName, dataType));
            //this.jTable1.revalidate();
            DataTableModel dataTableModel = new DataTableModel(_dataTable) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return true;
                }
            };
            this.jTable1.setModel(dataTableModel);
        } catch (Exception ex) {
            Logger.getLogger(FrmAttriData.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
Example 35
Project: Hospital-Management   File: Patient_Admit_roomRec1.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void Get_Data(){
     String sql="Select PatientRegistration.PatientID as 'Patient ID',PatientRegistration.PatientName as 'Patient Name',PatientRegistration.Gen as 'Gender',PatientRegistration.BG as 'Blood Group',Disease,AdmitDate as 'Admit Date',Room.RoomNo as 'Room No',Doctor.DoctorID as 'Doctor ID',DoctorName as 'Doctor Name',AdmitPatient_Room.AP_Remarks as 'Remarks' from Room,Doctor,PatientRegistration,AdmitPatient_Room where Room.RoomNo=AdmitPatient_Room.RoomNo and Doctor.DoctorID=AdmitPatient_Room.DoctorID and PatientRegistration.PatientID=AdmitPatient_Room.PatientID order by admitdate";
     try{
     pst=con.prepareStatement(sql);
      rs= pst.executeQuery();
     jTable1.setModel(DbUtils.resultSetToTableModel(rs));
     }catch(Exception e){
        JOptionPane.showMessageDialog(null, e);
     }
}
 
Example 36
Project: gameserver   File: ClipboardKeyAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void copyToClipboard(boolean isCut) {
	int numCols = table.getSelectedColumnCount();
	int numRows = table.getSelectedRowCount();
	int[] rowsSelected = table.getSelectedRows();
	int[] colsSelected = table.getSelectedColumns();
	if (numRows != rowsSelected[rowsSelected.length - 1] - rowsSelected[0] + 1
			|| numRows != rowsSelected.length
			|| numCols != colsSelected[colsSelected.length - 1] - colsSelected[0]
					+ 1 || numCols != colsSelected.length) {

		JOptionPane.showMessageDialog(null, "无效的拷贝",
				"无效的拷贝", JOptionPane.ERROR_MESSAGE);
		return;
	}

	StringBuffer excelStr = new StringBuffer();
	for (int i = 0; i < numRows; i++) {
		for (int j = 0; j < numCols; j++) {
			Object value = table.getValueAt(rowsSelected[i], colsSelected[j]);
			excelStr.append(escape(value));
			if (isCut) {
				table.setValueAt(null, rowsSelected[i], colsSelected[j]);
			}
			if (j < numCols - 1) {
				excelStr.append(CELL_BREAK);
			}
		}
		excelStr.append(LINE_BREAK);
	}

	StringSelection sel = new StringSelection(excelStr.toString());
	CLIPBOARD.setContents(sel, sel);
}
 
Example 37
Project: bigtable-sql   File: EditWhereColsPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Put the current data into the EditWhereCols table.
 */
public boolean ok() {
       
	// if all cols are in the "to use" side, delete from EditWhereCols
	if (notUseColsList.getModel().getSize() == 0) {
		_editWhereCols.put(_unambiguousTableName, null);
	}
	else {
		// some cols are not to be used
		ListModel useColsModel = useColsList.getModel();
		
		// do not let user remove everything from the list
		if (useColsModel.getSize() == 0) {
			JOptionPane.showMessageDialog(this,
				// i18n[editWhereColsPanel.cannotRemoveAllCols=You cannot remove all of the fields from the 'use columns' list.]
				s_stringMgr.getString("editWhereColsPanel.cannotRemoveAllCols"));
			return false;
		}
		
		// create the HashMap of names to use and put it in EditWhereCols
		HashMap<String, String> useColsMap = 
               new HashMap<String, String>(useColsModel.getSize());
		
		for (int i=0; i< useColsModel.getSize(); i++) {
			useColsMap.put((String)useColsModel.getElementAt(i), 
                              (String)useColsModel.getElementAt(i));
		}
		
		_editWhereCols.put(_unambiguousTableName, useColsMap);
	}
	return true;
}
 
Example 38
Project: uima-uimaj   File: CpmPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Start processing.
 */
private void startProcessing() {
  // Check that Collection Reader is selected
  if (collectionReaderDesc == null) {
    JOptionPane.showMessageDialog(CpmPanel.this, "No Collection Reader has been selected",
            "Error", JOptionPane.ERROR_MESSAGE);
    transportControlPanel.reset();
    resetScreen();
    return;
  }

  try {
    // update the parameter overrides according to GUI settings
    updateCpeDescriptionParameterOverrides();

    // intantiate CPE
    mCPE = null;  // to allow GC of previous ae's that may
                  // hold onto lots of memory e.g. OpenNLP
    mCPE = UIMAFramework.produceCollectionProcessingEngine(currentCpeDesc);

    // attach callback listener
    StatusCallbackListenerImpl statCbL = new StatusCallbackListenerImpl();
    mCPE.addStatusCallbackListener(statCbL);

    // start processing
    mCPE.process();
  } catch (Exception ex) {
    resetScreen();
    displayError(ex);
  }

}
 
Example 39
Project: jeddict   File: ResultSetMappingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private boolean validateField() {
    if (name_TextField.getText().trim().length() <= 0 /*|| Pattern.compile("[^\\w-]").matcher(this.id_TextField.getText().trim()).find()*/) {
        JOptionPane.showMessageDialog(this, "Name can't be empty", "Invalid Value", javax.swing.JOptionPane.WARNING_MESSAGE);
        return false;
    }//I18n
    if (entity == null) {
        io.github.jeddict.jpa.spec.Entity entitySpec = ((ComboBoxValue<io.github.jeddict.jpa.spec.Entity>) entity_ComboBox.getSelectedItem()).getValue();
        if (entitySpec == null) {
            JOptionPane.showMessageDialog(this, "Entity can't be empty", "Invalid Value", javax.swing.JOptionPane.WARNING_MESSAGE);
            return false;
        }//I18n
    }
    return true;
}
 
Example 40
Project: quickfix-messenger   File: CloseProjectActionListener.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e)
{
	int choice = JOptionPane.showConfirmDialog(frame,
			"Are you sure you want to close \""
					+ frame.getActiveXmlProject().getName() + "\"?",
			"Close Project", JOptionPane.YES_NO_OPTION);
	if (choice == JOptionPane.YES_OPTION)
	{
		if (frame.getActiveXmlProject() != null)
		{
			choice = JOptionPane.showConfirmDialog(frame,
					"Do you want to save \""
							+ frame.getActiveXmlProject().getName() + "\"?",
					"Save Current Project",
					JOptionPane.YES_NO_CANCEL_OPTION);
			switch (choice)
			{
			case JOptionPane.NO_OPTION:
				break;
			case JOptionPane.YES_OPTION:
				frame.marshallActiveXmlProject();
				break;
			case JOptionPane.CANCEL_OPTION:
				return;
			}
		}
		frame.setActiveXmlProject(null, null);
	}
}