List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException
From source file:controller.model.ControllerPsUsuarios.java
public PsUsuarios camposUsuarios(String[] argsLogin) { PsUsuarios psUsuariosLogin;/*from w w w. j av a2s. c om*/ // ctrlUsuariosJpaController = new PsUsuariosJpaController(); if (!argsLogin[0].equals("") && !argsLogin[1].equals("") && !argsLogin[2].equals("")) { psUsuariosLogin = new PsUsuarios(); psUsuariosLogin.setUsuario(argsLogin[0]); psUsuariosLogin.setPassword(argsLogin[1]); psUsuariosLogin.setEmpresa(argsLogin[2]); //System.out.println(""+psUsuariosLogin.getUsuario()); //ctrlUsuariosJpaController.getUsuario(psUsuariosLogin); return psUsuariosLogin; } JOptionPane.showMessageDialog(null, "Por favor completar todos los campos"); return null; }
From source file:MonitorSaurausRex.MainMenu.java
private boolean anyEncFileExists(File[] listOfFilesAndFolders) { for (File file : listOfFilesAndFolders) { String filePath = file.getAbsoluteFile().toString(); if (!file.isDirectory() && filePath.substring(filePath.length() - 4, filePath.length()).equals(".enc")) { System.out.println(file.getAbsoluteFile() + " is already encrypted"); Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(null, "1 or more files are already encrypted !! \nPlease de-select them."); return true; }/*w w w. j a v a 2 s . c o m*/ } return false; }
From source file:gui.accessories.DownloadProgressWork.java
@Override public void done() { setProgress(100);//from w w w .j a v a 2s . co m downloadFile.delete(); String successLabel = "Successful download and uncompress process. A total of " + filesCount + " portraits have been obtained."; JOptionPane.showMessageDialog(null, successLabel); }
From source file:PRC6.Graficos.java
@Override public void actionPerformed(ActionEvent e) { Object fuente = e.getSource(); if (fuente == das.getPlace()) JOptionPane.showMessageDialog(null, "Cambio registrado en el Sitio"); else if (fuente == das.getYear()) JOptionPane.showMessageDialog(null, "Cambio registrado en el Ao"); else if (fuente == das.getjComboBox1()) JOptionPane.showMessageDialog(null, "Cambio registrado en el Grafico"); int n = Integer.parseInt(das.getYear().getSelectedItem().toString()); int ini = das.get_pos(n); if (das.getjComboBox1().getSelectedIndex() == 0) das.graph.PieGraphF(das.getDataset().getTmax(), ini, das.getjComboBox1().getSelectedItem().toString(), das.getYear().getSelectedItem().toString(), das.getjPanel2(), das.getPlace().getSelectedItem().toString()); else if (das.getjComboBox1().getSelectedIndex() == 1) das.graph.PieGraphF(das.getDataset().getTmin(), ini, das.getjComboBox1().getSelectedItem().toString(), das.getYear().getSelectedItem().toString(), das.getjPanel2(), das.getPlace().getSelectedItem().toString()); else if (das.getjComboBox1().getSelectedIndex() == 2) das.graph.PieGraphI(das.getDataset().getAfdays(), ini, das.getjComboBox1().getSelectedItem().toString(), das.getYear().getSelectedItem().toString(), das.getjPanel2(), das.getPlace().getSelectedItem().toString()); else if (das.getjComboBox1().getSelectedIndex() == 3) das.graph.PieGraphF(das.getDataset().getRain(), ini, das.getjComboBox1().getSelectedItem().toString(), das.getYear().getSelectedItem().toString(), das.getjPanel2(), das.getPlace().getSelectedItem().toString()); else if (das.getjComboBox1().getSelectedIndex() == 4) das.graph.PieGraphF(das.getDataset().getSun(), ini, das.getjComboBox1().getSelectedItem().toString(), das.getYear().getSelectedItem().toString(), das.getjPanel2(), das.getPlace().getSelectedItem().toString()); }
From source file:application.bbdd.pool.java
public static void realizaConsulta2() { Connection conexion = null;/* w ww . ja v a2 s . co m*/ Statement sentencia = null; ResultSet rs = null; try { conexion = getConexion(); sentencia = conexion.createStatement(); rs = sentencia.executeQuery("select count(*) from db"); rs.next(); JOptionPane.showMessageDialog(null, "El numero de bd es: " + rs.getInt(1)); logStatistics(); } catch (SQLException e) { JOptionPane.showMessageDialog(null, e.toString()); } finally { try { rs.close(); sentencia.close(); liberaConexion(conexion); } catch (Exception fe) { JOptionPane.showMessageDialog(null, fe.toString()); } } }
From source file:fuel.gui.stats.StationStatsPanel.java
private void refreshGraphs() { graphContainer.removeAll();//from w ww. ja v a 2s . c om DefaultPieDataset usageDataset = new DefaultPieDataset(); try { for (Station station : database.getStations()) { ResultSet thisStation = database .Query("SELECT SUM(liter) FROM fuelrecords WHERE stationId = " + station.getId(), true); thisStation.next(); usageDataset.setValue(station.toString(), thisStation.getInt("1")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart usagePieChart = ChartFactory.createPieChart3D("", usageDataset, true, true, false); PiePlot3D plot3 = (PiePlot3D) usagePieChart.getPlot(); plot3.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel usagePieChartPanel = new ChartPanel(usagePieChart); usagePieChartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Tankstation verhouding"))); usagePieChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); DefaultPieDataset fuelDataset = new DefaultPieDataset(); try { ResultSet numberResults = database.Query("SELECT DISTINCT typeOfGas FROM fuelrecords", true); while (numberResults.next()) { ResultSet thisStation = database.Query("SELECT SUM(liter) FROM fuelrecords WHERE typeOfGas = '" + numberResults.getString("typeOfGas") + "'", true); thisStation.next(); fuelDataset.setValue(numberResults.getString("typeOfGas"), thisStation.getInt("1")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart fuelPieChart = ChartFactory.createPieChart3D("", fuelDataset, true, true, false); PiePlot3D plot2 = (PiePlot3D) fuelPieChart.getPlot(); plot2.setForegroundAlpha(0.6f); //plot3.setCircular(true); JPanel fuelPieChartPanel = new ChartPanel(fuelPieChart); fuelPieChartPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createTitledBorder("Brandstof verhouding"))); fuelPieChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); DefaultCategoryDataset barDataset = new DefaultCategoryDataset(); try { ResultSet motorThing = database.Query("SELECT cost/liter,date FROM fuelrecords ORDER BY date ASC", true); while (motorThing.next()) { barDataset.addValue(motorThing.getDouble("1"), motorThing.getString("date"), "Prijs per liter"); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage() + ex.getCause()); } JFreeChart barChart = ChartFactory.createBarChart3D("", // chart title "", // domain axis label "Aantal", // range axis label barDataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = barChart.getCategoryPlot(); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); ChartPanel barChartPanel = new ChartPanel(barChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder("Prijs per liter")); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); JPanel piePanel = new JPanel(new GridLayout(0, 2)); piePanel.add(usagePieChartPanel); piePanel.add(fuelPieChartPanel); graphContainer.add(piePanel); graphContainer.add(barChartPanel); revalidate(); repaint(); }
From source file:ViewDB.java
public ViewDBFrame() { setTitle("ViewDB"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); tableNames = new JComboBox(); tableNames.addActionListener(new ActionListener() {/* w w w .j a va 2s . c o m*/ public void actionPerformed(ActionEvent event) { showTable((String) tableNames.getSelectedItem()); } }); add(tableNames, BorderLayout.NORTH); try { readDatabaseProperties(); Connection conn = getConnection(); try { DatabaseMetaData meta = conn.getMetaData(); ResultSet mrs = meta.getTables(null, null, null, new String[] { "TABLE" }); while (mrs.next()) tableNames.addItem(mrs.getString(3)); } finally { conn.close(); } } catch (SQLException e) { JOptionPane.showMessageDialog(this, e); } catch (IOException e) { JOptionPane.showMessageDialog(this, e); } JPanel buttonPanel = new JPanel(); add(buttonPanel, BorderLayout.SOUTH); previousButton = new JButton("Previous"); previousButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { showPreviousRow(); } }); buttonPanel.add(previousButton); nextButton = new JButton("Next"); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { showNextRow(); } }); buttonPanel.add(nextButton); deleteButton = new JButton("Delete"); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { deleteRow(); } }); buttonPanel.add(deleteButton); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveChanges(); } }); buttonPanel.add(saveButton); }
From source file:oneDrive.OneDriveAPI.java
public static void createNewLogin(String url) throws IOException, ProtocolException, MalformedURLException { String accessURL;/*from w ww . j av a 2s . co m*/ String jsonURL; String[] tokens; accessURL = url; AUTH_CODE = getCodefromURL(accessURL); //Build the Auth_token path AUTH_TOKEN_URL = "https://login.live.com/oauth20_token.srf?client_id=" + CLIENT_ID + "&client_secret=" + CLIENT_SECRET + "&code=" + AUTH_CODE + "&grant_type=authorization_code&redirect_uri=https://login.live.com/oauth20_desktop.srf"; // Get the tockens in json format jsonURL = connectWithREST(AUTH_TOKEN_URL, GET); try { tokens = jsonParse(jsonURL); ACCESS_TOKEN = tokens[0]; REFRESH_TOKEN = tokens[1]; //Save Refresh token to the file createNewTokenFile(REFRESH_TOKEN); } catch (JSONException ex) { Logger.getLogger(OneDriveAPI.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage()); } }
From source file:fitmon.PieChart.java
/** * Creates a sample dataset./*from ww w . j a v a 2 s .co m*/ * * @return A sample dataset. */ public PieDataset createDataset() { try { Class.forName("com.mysql.jdbc.Driver"); /*st = conn.prepareStatement();*/ Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/fitmon", "root", "april-23"); Statement st = conn.createStatement(); String query = "select sum(protein), sum(carbs), sum(fat), sum(fiber)from Diet group by date limit 5 ;"; System.out.println(query); try (ResultSet rs = st.executeQuery(query)) { while (rs.next()) { //Retrieve by column name //for (int i=0; i<4; i++){ Double prot = rs.getDouble("sum(protein)"); protein += prot; System.out.println(protein); Double carb = (rs.getDouble("sum(carbs)")); carbo += carb; Double fats = (rs.getDouble("sum(fat)")); fat += fats; Double fib = (rs.getDouble("sum(fiber)")); fiber += fib; //} } } } catch (ClassNotFoundException | SQLException e) { JOptionPane.showMessageDialog(this, "Error"); } DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(protein, protein); dataset.setValue(carbo, carbo); dataset.setValue(fiber, fiber); dataset.setValue(fat, fat); //dataset.setValue("Five", new Double(11.0)); //dataset.setValue("Six", new Double(19.4)); return dataset; }
From source file:lince.controladores.exportar.AbrirExportarHoisan.java
@Override public void execute() { if (fc == null) { fc = new JFileChooser(); //Add a custom file filter and disable the default fc.addChoosableFileFilter(new FiltroArchivos("mdb", ResourceBundleHelper.getI18NLabel("HOISAN"))); fc.setAcceptAllFileFilterUsed(false); }//from w w w . jav a 2 s .co m //Show it. int returnVal = fc.showDialog(LinceFrame.getInstance(), ResourceBundleHelper.getI18NLabel("actions.export.Hoisan.confirm")); //Process the results. if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); log.warn("Init export to Hoisan file: " + file.getName() + "."); HoisanTool hoisan = new HoisanTool(); String result = hoisan.exportFile(file); String message = ResourceBundleHelper.getI18NLabel( StringUtils.isEmpty(result) ? "action.result.export.ok" : "action.result.export.fail"); if (StringUtils.isNotEmpty(result)) { message = message + "\n" + result; } JOptionPane.showMessageDialog(LinceFrame.getInstance(), message); } else { log.warn("Hoisan export cancelled by user."); } //Reset the file chooser for the next time it's shown. fc.setSelectedFile(null); }