Java Code Examples for javax.swing.JOptionPane.showMessageDialog()

The following are Jave code examples for showing how to use showMessageDialog() of the javax.swing.JOptionPane class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Java_Swing_Programming   File: Frm_KullaniciSayfasi.java   View Source Code Vote up 7 votes
private void btn_ekleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ekleActionPerformed
    // TODO add your handling code here:
    if (tbl_kisiliste.getSelectedRow() < 0) {
        JOptionPane.showMessageDialog(rootPane, "Bir kullanıcı Seçmelisiniz");
        return;
    }
    String kullaniciadi = dtm1.getValueAt(tbl_kisiliste.getSelectedRow(), 0).toString();
    for (USER user : USER.Kullanicilar) {
        if (user.KullaniciAdi.compareTo(kullaniciadi) == 0) {
            user.ArkadaslikIstekleri.add(Frm_Login.loginuser);

            break;
        }
    }


}
 
Example 2
Project: sbc-qsystem   File: UBForm.java   View Source Code Vote up 7 votes
private void buttonStopTestCOMActionPerformed(
    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopTestCOMActionPerformed
    buttonTestCOM.setEnabled(true);
    buttonStopTestCOM.setEnabled(false);
    panelDev.setEnabled(false);
    buttonSendSignal.setEnabled(false);
    buttonChangeAdress.setEnabled(false);
    buttonTestDev.setEnabled(false);
    if (port != null) {
        try {
            port.free();
        } catch (Exception ex) {
            System.err.println(ex);
            textDebug.setText("Порт не закрылся. " + ex);
            JOptionPane.showMessageDialog(this,
                "Порт не закрылся. " + ex,
                "Отсыл",
                JOptionPane.ERROR_MESSAGE);
            throw new RuntimeException(ex);
        }
    }
    textDebug.setText("... Порт закрылся\n" + textDebug.getText());
}
 
Example 3
Project: AgentWorkbench   File: LogFileOptions.java   View Source Code Vote up 6 votes
/**
 * Writes the form data to the properties file.
 */
private void setFormData2Global() {
	String logBasePath = this.getJTextLoggingBasePath().getText();
	if (logBasePath==null || (logBasePath!=null && logBasePath.trim().equals(""))) {
		Application.getGlobalInfo().setLoggingBasePath(null);
	} else {
		// --- Check the settings -------------------------------
		String notValidMessage = this.isValidDestinationDirectory(logBasePath);
		if (notValidMessage!=null) {
			// --- Error with the current settings --------------
			String title = Language.translate("Log-Datei Konfiguration");
			JOptionPane.showMessageDialog(this, notValidMessage, title, JOptionPane.ERROR_MESSAGE);
			return;
		}
		Application.getGlobalInfo().setLoggingBasePath(logBasePath.trim());
	}
	Application.getGlobalInfo().setLoggingEnabled(this.getJCheckBoxLoggingEnabled().isSelected());
}
 
Example 4
Project: PPRCarTrade   File: TelaCadastro.java   View Source Code Vote up 6 votes
private void btn_CadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CadastrarActionPerformed
    // TODO add your handling code here:
    String login = jtf_login.getText();
    String senha = jtf_senha.getText();
    String nome = jtf_Nome.getText();
    String rg = jtf_RG.getText();
    String cpf = jtf_CPF.getText();
    String telefone = jtf_Telefone.getText();
    String email = jtf_Email.getText();
    String endereco = jtf_Endereco.getText();
    String cartMotorista = jtf_CartMotorista.getText();
    if(NegocioFacade.checaCadastro(login, senha, nome, rg, cpf, endereco, cartMotorista, telefone, email)){
        NegocioFacade.registrarUsuario(new EDA.Usuario(login, senha, nome, rg, cpf, endereco, cartMotorista, telefone, email, new Comentario("")));
        JOptionPane.showMessageDialog(this, "Cadastro efetuado com sucesso!", "Cadastrado!", JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
    } else {
        JOptionPane.showMessageDialog(this, NegocioFacade.getStatus().getErro(), "Erro!", JOptionPane.ERROR_MESSAGE);
    }
}
 
Example 5
Project: BlackjackProjectJava   File: BlackjackProjectDriver.java   View Source Code Vote up 6 votes
private void helpJButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_helpJButtonActionPerformed
{//GEN-HEADEREND:event_helpJButtonActionPerformed
    String helpText =
      "INSTRUCTIONS: \n" +
      "Welcome to Blackjack(also known as 21)! The main objective of\n" +
      "this game is to get the closest to the number 21 without going\n" +
      "over. The player will be given two cards at the start of the\n" +
      "game. In addition, the dealer will also be given two cards.\n" +
      "The player will only know the dealer's first card. From this, \n" +
      "the player can get another card or stay with the cards they have.\n" +
      "All cards are worth their numeric value, with royals being worth\n" +
      "10 points, and ace being 1 or 11 depending on the situation.\n" +
      "Whoever has the closest total to 21 at the end wins the game!\n" +
      "Good Luck and Remember to have fun!\n";
    JOptionPane.showMessageDialog(rootPane, helpText);
}
 
Example 6
Project: jmt   File: MainJwatWizard.java   View Source Code Vote up 5 votes
private void abortEvent(EventFinishAbort e) {
	JWatWizard wizard = (JWatWizard) ((WizardPanel) tabbedPane.getComponentAt(currentPanel)).getParentWizard();
	JOptionPane.showMessageDialog(tabbedPane.getComponentAt(currentPanel), e.getMessage(), "LOADING ABORTED!!", JOptionPane.WARNING_MESSAGE);
	((InputPanel) tabbedPane.getComponentAt(JWATConstants.WORKLOAD_INPUT_PANEL)).setCanGoForward(false);
	wizard.setEnableButton("Next >", false);
	wizard.setEnableButton("Solve", false);
}
 
Example 7
Project: RA-Reader   File: RegisterAuszugGUI.java   View Source Code Vote up 5 votes
public RegisterAuszugGUI(int regNr, int zuNr) {
    try {
        initComponents();
        this.regNr = regNr;
        this.zuNr = zuNr;
        it = new InfoTable(regNr, zuNr);
        tb_info.setModel(it);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "Error: ZuNr oder RegNr falsch.");
        System.exit(1);
    }
}
 
Example 8
Project: schneckenrennen   File: RaceFrame.java   View Source Code Vote up 5 votes
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
Font font = new JLabel().getFont();

// Load HTML and set style to match the application's style
String html
	= Translations.get(
		"RaceFrame.help.about",
		font.getFamily(),
		(font.isBold() ? "bold" : "normal"),
		"" + font.getSize() + "pt");

// Create HTML content pane
JEditorPane ep = new JEditorPane("text/html", html);

// Handle link clicks
ep.addHyperlinkListener((HyperlinkEvent e) -> {
    if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
	try {
	    Desktop.getDesktop().browse(e.getURL().toURI());
	} catch (IOException | URISyntaxException ex) {
	    Logger.getLogger(RaceFrame.class.getName()).log(Level.SEVERE, null, ex);
	}
    }
});
ep.setEditable(false);
ep.setBackground(new JOptionPane().getBackground());

// Show dialog
JOptionPane.showMessageDialog(null, ep);
   }
 
Example 9
Project: DicomViewer   File: DicomReader.java   View Source Code Vote up 5 votes
private void saveImage2(String asciiFN) {        
    int rows = image.rows;
    int cols = image.cols;
    int bpp = image.colorDepth;
    
    BufferedImage img = new BufferedImage(cols, rows, BufferedImage.TYPE_INT_RGB);
    final int[] buff = ((DataBufferInt) img.getRaster().getDataBuffer()).getData(); 
    
    try {
        int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for (int j = 0; j < cols; j++) {                
            for (int i = 0; i < rows; i++) {
                // Color depth check
                if (bpp == 16) { 
                    dicomFile.read(buff2);
                    tempBuff = (((0xff & buff2[1]) <<  8) | (0xff & buff2[0]));
                } else if (bpp == 8) {
            	dicomFile.read(buff1);
                    tempBuff = (0xff & buff1[0]);
                } // End of if-else block
                if (tempBuff!= 63536) {
                   if (tempBuff>max) max = tempBuff;
                    if (tempBuff<min) min = tempBuff;
                    int c = (254*tempBuff)/2358;
                    buff[j*rows+i] = (c<<16) + (c<<8) + (c);
                }
            	
            } // End of for block
        } // End of for block
        System.out.print("limits : min="+min+" max="+max);
    } catch (IOException ioe) {
        System.err.println(ioe);
        JOptionPane.showMessageDialog(null, ioe, "Exception", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } // End of try-catch block
     try {
        File outputfile = new File(asciiFN+".png");
        ImageIO.write(img, "png", outputfile);
    } catch (IOException e) {

    }
}
 
Example 10
Project: pdfjumbler   File: PdfJumbler.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	try {
		PdfProcessingFactory.setEditorClass(editorClass);
	}
	catch (Exception ex) {
		ex.printStackTrace();
		JOptionPane.showMessageDialog(parent, ex.getLocalizedMessage(), ex.getClass().getSimpleName(), JOptionPane.ERROR_MESSAGE);
	}
}
 
Example 11
Project: 20170612-NotaFIscalEletronica   File: FrameInicial.java   View Source Code Vote up 5 votes
private void actionRemove(){
	
	remove = new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {
			
			if (tabela.getSelectedRow()==-1){
				JOptionPane.showMessageDialog(null, "Selecione o registro a ser apagado","Alerta", JOptionPane.PLAIN_MESSAGE);
				return;
			}
			Object[] options = {"Sim", "Não"};
			int n = JOptionPane.showOptionDialog(null, "Deseja realmente apagar o registro: "+tabela.getSelectedRow(), "Alerta", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE, null, options,options[0] );
			
			if (n == 1){
				return;
			}
			
			EntityManager em = Persistence.createEntityManagerFactory("notaFiscal_unit").createEntityManager();
			em.getTransaction().begin();
			
			String j =""+tabela.getValueAt(tabela.getSelectedRow(), 0);
			long i = Long.parseLong(j);
			Query q = em.createQuery("delete from Nf n " 
					+ "where n.notaFiscalNumero = :name");
			q.setParameter("name", i);
			int deleted = q.executeUpdate();	  
				  
			em.getTransaction().commit();
			em.close();
			
			model.removeRow(tabela.getSelectedRow());
			
		}
	};
}
 
Example 12
Project: ProyectoTestUnitario   File: HacerEjercicioAlumno.java   View Source Code Vote up 5 votes
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
   if(e.resultado==parseInt(jTextField1.getText())){
    
   a.puntajeAcumulado=a.puntajeAcumulado + e.puntaje;
   a.nivel.numeroNivel = Alumno.calcularNuevoNivel(a.puntajeAcumulado);
   try {
   ConectarBD con1 = new ConectarBD();
        Connection cnUp=null;
       
           cnUp = con1.getCon();
       
            
            String sql = "UPDATE alumno SET puntajeAcumulado= ?, numeroNivel= ? WHERE usuario= ? AND contrasenia= ? ";
            
            PreparedStatement st = cnUp.prepareStatement(sql);
            
            st.setInt(1, a.puntajeAcumulado);
            st.setInt(2, a.nivel.numeroNivel);
            st.setString(3, a.usuario);
            st.setString(4, a.contrasenia);
            
            st.executeUpdate();
            
 
            
            
   this.setVisible(false);
   } catch (SQLException ex) {
           Logger.getLogger(HacerEjercicioAlumno.class.getName()).log(Level.SEVERE, null, ex);
       }
   JOptionPane.showMessageDialog(null, "Correcto!");
   } else{
    JOptionPane.showMessageDialog(null, "Incorrecto!"); 
    this.setVisible(false);}
}
 
Example 13
Project: OpenDA   File: PlotFrame.java   View Source Code Vote up 5 votes
public void actionPerformed(ActionEvent e) {
    JMenuItem target = (JMenuItem)e.getSource();
    String actionCommand = target.getActionCommand();
    try {
        if (actionCommand.equals("Open")) {
            _open();
        } else if (actionCommand.equals("Save")) {
            _save();
        } else if (actionCommand.equals("SaveAs")) {
            _saveAs();
        } else if (actionCommand.equals("Export")) {
            _export();
        } else if (actionCommand.equals("Print")) {
            _print();
        } else if (actionCommand.equals("Close")) {
            _close();
        }
    } catch (Exception exception) {
        // If we do not catch exceptions here, then they
        // disappear to stdout, which is bad if we launched
        // where there is no stdout visible.
        JOptionPane.showMessageDialog(null,
                "File Menu Exception:\n" + exception.toString(),
                "Ptolemy Plot Error", JOptionPane.WARNING_MESSAGE);

    }
    // NOTE: The following should not be needed, but there jdk1.3beta
    // appears to have a bug in swing where repainting doesn't
    // properly occur.
    repaint();
}
 
Example 14
Project: jaer   File: AEViewer.java   View Source Code Vote up 5 votes
private void monSeqOpMode1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monSeqOpMode1ActionPerformed
           if (aemon instanceof CypressFX2MonitorSequencer) {
               CypressFX2MonitorSequencer fx = (CypressFX2MonitorSequencer) aemon;
               try {
                   fx.setOperationMode(1);
                   JOptionPane.showMessageDialog(this, "Timestamp tick set to " + fx.getOperationMode() + " us. Note that jAER will treat the ticks as 1us anyway.");
               } catch (Exception e) {
                   e.printStackTrace();
                   aemon.close();
               }
           }
}
 
Example 15
Project: Tarski   File: EditorActions.java   View Source Code Vote up 5 votes
/**
 * Reads XML+PNG format.
 */
protected void openXmlPng(BasicGraphEditor editor, File file)
		throws IOException
{
	Map<String, String> text = mxPngTextDecoder
			.decodeCompressedText(new FileInputStream(file));

	if (text != null)
	{
		String value = text.get("mxGraphModel");

		if (value != null)
		{
			Document document = mxXmlUtils.parseXml(URLDecoder.decode(
					value, "UTF-8"));
			mxCodec codec = new mxCodec(document);
			codec.decode(document.getDocumentElement(), editor
					.getGraphComponent().getGraph().getModel());
			editor.setCurrentFile(file);
			resetEditor(editor);

			return;
		}
	}

	JOptionPane.showMessageDialog(editor,
			mxResources.get("imageContainsNoDiagramData"));
}
 
Example 16
Project: QN-ACTR-Release   File: DescriptionPanel.java   View Source Code Vote up 4 votes
@Override
public void help() {
	JOptionPane.showMessageDialog(this, helpText, "Help", JOptionPane.INFORMATION_MESSAGE);
}
 
Example 17
Project: JavaClass   File: Suite.java   View Source Code Vote up 4 votes
public static void main(String[] args) {
	Suite maSuite = new Suite();
	JOptionPane.showMessageDialog(null, maSuite.genererMultiple10());
}
 
Example 18
Project: Tarski   File: EditorActions.java   View Source Code Vote up 4 votes
/**
 * 
 */
public void actionPerformed(ActionEvent e)
{
	if (e.getSource() instanceof mxGraphComponent)
	{
		mxGraphComponent graphComponent = (mxGraphComponent) e
				.getSource();
		mxGraph graph = graphComponent.getGraph();
		mxIGraphModel model = graph.getModel();

		Object source = null;
		Object target = null;

		Object[] cells = graph.getSelectionCells();

		for (int i = 0; i < cells.length; i++)
		{
			if (model.isVertex(cells[i]))
			{
				if (source == null)
				{
					source = cells[i];
				}
				else if (target == null)
				{
					target = cells[i];
				}
			}

			if (source != null && target != null)
			{
				break;
			}
		}

		if (source != null && target != null)
		{
			int steps = graph.getChildEdges(graph.getDefaultParent()).length;
			Object[] path = mxGraphAnalysis.getInstance()
					.getShortestPath(graph, source, target,
							new mxDistanceCostFunction(), steps,
							directed);
			graph.setSelectionCells(path);
		}
		else
		{
			JOptionPane.showMessageDialog(graphComponent,
					mxResources.get("noSourceAndTargetSelected"));
		}
	}
}
 
Example 19
Project: osumer   File: Main.java   View Source Code Vote up 4 votes
public static void runBrowser(Config config, String[] args) {
    String argstr = buildArgStr(args);
    // Run the default browser application
    if (!GraphicsEnvironment.isHeadless() && Osumer.isWindows()) {

        System.out.println(config.getDefaultBrowser());
        if (config.getDefaultBrowser() == null || config.getDefaultBrowser().isEmpty()) {
            System.out.println(config.getDefaultBrowser());
            JOptionPane.showInputDialog(null,
                    "No default browser path is specified. Please maunally launch the browser the following arguments:",
                    "osumer - Automatic browser switching", JOptionPane.INFORMATION_MESSAGE, null, null, argstr);
            System.exit(-1);
            return;
        }

        String browserPath = Installer.getBrowserExePath(config.getDefaultBrowser());
        System.out.println(browserPath);
        if (browserPath == null) {
            JOptionPane.showMessageDialog(null,
                    "Cannot read browser executable path in registry.\nCannot start default browser application for:\n"
                            + argstr,
                    "Configuration Error", JOptionPane.ERROR_MESSAGE);
            System.exit(-1);
            return;
        }

        File file = new File(browserPath.replaceAll("\"", ""));
        if (!file.exists()) {
            JOptionPane.showMessageDialog(null,
                    "The specified browser application does not exist.\nCannot start default browser application for:\n"
                            + argstr,
                    "Configuration Error", JOptionPane.ERROR_MESSAGE);
            System.exit(-1);
            return;
        }

        try {
            Runtime.getRuntime().exec(browserPath + " " + argstr);
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.exit(0);
        return;
    }
}
 
Example 20
Project: Moenagade   File: Project.java   View Source Code Vote up 4 votes
private boolean compile()
{
    // get all the files content
    Hashtable<String,String> codes = new Hashtable<>();
    String dir = directoryName+System.getProperty("file.separator")+"src";
    Collection files = FileUtils.listFiles(new File(dir), new String[] {"java"}, true);
    for (Iterator iterator = files.iterator(); iterator.hasNext();) 
    {
        File file = (File) iterator.next();   
        try 
        {
            codes.put(file.getPath().substring(dir.length()+1).replace(System.getProperty("file.separator"), ".").replace(".java", ""),IOUtils.toString(file.toURI(), "utf-8"));
        } 
        catch (IOException ex2) 
        {
            JOptionPane.showMessageDialog(frame, "Error while saving world (base) source!\n"+
                ex2.getMessage()+"\n","Error", JOptionPane.ERROR_MESSAGE,Moenagade.IMG_ERROR);
            ex2.printStackTrace();
        }
    }
    
    // compile 
    try 
    {
        //Runtime6.getInstance().executeCommand("System.setProperty(\"user.dir\",\"" + directoryName + "\")");
        Runtime6.getInstance().setRootDirectory(directoryName+System.getProperty("file.separator")+"src");
        Runtime6.getInstance().compile(codes, "");
        //Runtime6.getInstance().compileToPath(sourceFiles, directoryName+System.getProperty("file.separator")+"bin", "7", "");
    } 
    catch (ClassNotFoundException ex) 
    {
        JOptionPane.showMessageDialog(frame, "Error while compiling!\n"+
            ex.getMessage()+"\n","Error", JOptionPane.ERROR_MESSAGE,Moenagade.IMG_ERROR);
        Console.disconnectAll();
        ex.printStackTrace();
        Console.connectAll();
        return false;
    } 
    
    return true;
}