javax.swing.JOptionPane Java Examples

The following examples show how to use javax.swing.JOptionPane. 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: FontificatorProperties.java    From ChatGameFontificator with 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 #2
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 #3
Source File: DemoChecker.java    From ramus with 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 #4
Source File: ViewerFrame.java    From djl-demo with 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 #5
Source File: BotFrame.java    From BotLibre with 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 #6
Source File: LearnView.java    From iBioSim with 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 #7
Source File: SimpleBrowser.java    From WorldPainter with 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 #8
Source File: UserMessageHelper.java    From openAGV with 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 #9
Source File: PCGenFrame.java    From pcgen with 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 #10
Source File: ReadedModel.java    From ramus with 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 #11
Source File: Utils.java    From beast-mcmc with 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 #12
Source File: ResultSetMappingsPanel.java    From jeddict with 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 #13
Source File: CloseProjectActionListener.java    From quickfix-messenger with 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);
	}
}
 
Example #14
Source File: BirdController.java    From JavaMainRepo with 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 #15
Source File: PlotFrame.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void _about() {
    JOptionPane.showMessageDialog(this,
            "PlotFrame class\n" +
            "By: Edward A. Lee, [email protected] " +
            "and Christopher Hylands, [email protected]\n" +
            "Version " + PlotBox.PTPLOT_RELEASE +
            ", Build: $Id: PlotFrame.java,v 1.64 2003/04/12 10:49:33 cxh Exp $\n\n"+
            "For more information, see\n" +
            "http://ptolemy.eecs.berkeley.edu/java/ptplot\n\n" +
            "Copyright (c) 1997-2003, " +
            "The Regents of the University of California.",
            "About Ptolemy Plot", JOptionPane.INFORMATION_MESSAGE);
}
 
Example #16
Source File: DKeyUsage.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private void okPressed() {
	if (!jcbDigitalSignature.isSelected() && !jcbNonRepudiation.isSelected() && !jcbKeyEncipherment.isSelected()
			&& !jcbDataEncipherment.isSelected() && !jcbKeyAgreement.isSelected()
			&& !jcbCertificateSigning.isSelected() && !jcbCrlSign.isSelected() && !jcbEncipherOnly.isSelected()
			&& !jcbDecipherOnly.isSelected()) {
		JOptionPane.showMessageDialog(this, res.getString("DKeyUsage.ValueReq.message"), getTitle(),
				JOptionPane.WARNING_MESSAGE);
		return;
	}

	int keyUsageIntValue = 0;
	keyUsageIntValue |= jcbDigitalSignature.isSelected() ? KeyUsage.digitalSignature : 0;
	keyUsageIntValue |= jcbNonRepudiation.isSelected() ? KeyUsage.nonRepudiation : 0;
	keyUsageIntValue |= jcbKeyEncipherment.isSelected() ? KeyUsage.keyEncipherment : 0;
	keyUsageIntValue |= jcbDataEncipherment.isSelected() ? KeyUsage.dataEncipherment : 0;
	keyUsageIntValue |= jcbKeyAgreement.isSelected() ? KeyUsage.keyAgreement : 0;
	keyUsageIntValue |= jcbCertificateSigning.isSelected() ? KeyUsage.keyCertSign : 0;
	keyUsageIntValue |= jcbCrlSign.isSelected() ? KeyUsage.cRLSign : 0;
	keyUsageIntValue |= jcbEncipherOnly.isSelected() ? KeyUsage.encipherOnly : 0;
	keyUsageIntValue |= jcbDecipherOnly.isSelected() ? KeyUsage.decipherOnly : 0;

	KeyUsage keyUsage = new KeyUsage(keyUsageIntValue);

	try {
		value = keyUsage.getEncoded(ASN1Encoding.DER);
	} catch (IOException e) {
		DError.displayError(this, e);
		return;
	}

	closeDialog();
}
 
Example #17
Source File: WhiteRabbitMain.java    From WhiteRabbit with Apache License 2.0 5 votes vote down vote up
private void fakeDataRun() {
	String filename = scanReportFileField.getText();
	if (!new File(filename).exists()) {
		String message = "File " + filename + " not found";
		JOptionPane.showMessageDialog(frame, StringUtilities.wordWrap(message, 80), "File not found", JOptionPane.ERROR_MESSAGE);
	} else {
		FakeDataThread thread = new FakeDataThread();
		thread.start();
	}
}
 
Example #18
Source File: PCGenActionMap.java    From pcgen with 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 #19
Source File: Process_SetWorkPosition.java    From sourcerabbit-gcode-sender with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void Execute()
{
    String commandStr = "G92 X" + fX + " Y" + fY + " Z" + fZ;
    GCodeCommand command = new GCodeCommand(commandStr);
    String response = ConnectionHelper.ACTIVE_CONNECTION_HANDLER.SendGCodeCommandAndGetResponse(command);
    if (response.toLowerCase().equals("ok"))
    {
        JOptionPane.showMessageDialog(fMyParentForm, "Work position changed!");
    }
    else
    {
        JOptionPane.showMessageDialog(fMyParentForm, "Something went wrong.Reset the GRBL controller and try again.", "Error", JOptionPane.ERROR_MESSAGE);
    }
}
 
Example #20
Source File: DGenerateKeyPair.java    From portecle with 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 #21
Source File: ManipulandoArquivo.java    From dctb-utfpr-2018-1 with 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 #22
Source File: Login.java    From dctb-utfpr-2018-1 with 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 #23
Source File: DocRec.java    From Hospital-Management with 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 #24
Source File: Misc.java    From swingsane with 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 #25
Source File: MainPanel.java    From jpexs-decompiler with 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 #26
Source File: FrmAttriData.java    From MeteoInfo with 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 #27
Source File: Patient_Admit_roomRec1.java    From Hospital-Management with 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 #28
Source File: ClipboardKeyAdapter.java    From gameserver with 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 #29
Source File: EditWhereColsPanel.java    From bigtable-sql with 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 #30
Source File: CpmPanel.java    From uima-uimaj with 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);
  }

}