Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showMessageDialog.

Prototype

public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Brings up an information-message dialog titled "Message".

Usage

From source file:framework.classes.connectionDB.java

/**
 * Open the conection in the Data base// w  w  w . j a va2 s  .c  o  m
 *
 * @return
 */
public static Connection gettingConnection() {

    Connection con = null;
    try {
        //            Class.forName("com.mysql.jdbc.Driver");
        //            String urlOdbc = "jdbc:mysql://127.0.0.1:3306/app";
        //            con = (Connection) (java.sql.DriverManager.getConnection(urlOdbc, "root", "root"));
        con = dataSource.getConnection();
    } catch (Exception e) {

        JOptionPane.showMessageDialog(null, "Ha sido imposible establecer la conexion!");
    }
    return con;
}

From source file:Main.java

private static void SaveCustomerFile(Document CustomerDoc, JFrame mainFrame) {
    try {/* w  w w.j  a  v a  2  s . c o  m*/
        TransformerFactory Factory = TransformerFactory.newInstance();
        Transformer Trans = Factory.newTransformer();
        DOMSource source = new DOMSource(CustomerDoc);
        File f = new File(".");
        String FilePath = f.getAbsoluteFile().getParent() + "\\Customers.xml";
        f = new File(FilePath);
        if (f.exists()) {
            f.delete();
        }
        StreamResult Result = new StreamResult(f);
        Trans.setOutputProperty(OutputKeys.INDENT, "yes");
        Trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "7");
        Trans.transform(source, Result);
    } catch (TransformerException ex) {
        System.out.println(ex.getMessage());
        JOptionPane.showMessageDialog(mainFrame,
                "There Was an Error Saving The File. Please Restart the Application.");
        System.exit(1);
    }
}

From source file:Main.java

public Main() {
    button.setToolTipText("Press the button !");
    button.addActionListener(e -> {/*from w w w  . j  a  v  a2 s.  c o  m*/
        JOptionPane.showMessageDialog(button.getParent(), "This disables ToolTips!");
        button.setToolTipText("This is Java! There is no help");
    });
    add(button);
}

From source file:TickTockInner.java

private void go() {
    Timer t = new Timer(1000, new Ticker());
    t.start();//  w  ww .  jav  a2  s  .c o  m
    JOptionPane.showMessageDialog(null, "Click OK to exit program");
    System.exit(0);
}

From source file:MyActionListener.java

public void actionPerformed(ActionEvent e) {
    JButton source = (JButton) e.getSource();
    String buttonText = source.getText();
    JOptionPane.showMessageDialog(null, "You clicked" + buttonText);
}

From source file:anslab2.Test.java

public static boolean typesMatch(String _input, int dataType) {

    if (dataType == 1) {
        //parse sa Alphabetic
        Pattern p = Pattern.compile("^[a-zA-Z]*$");
        Matcher m = p.matcher(_input);
        if (!m.matches()) {
            JOptionPane.showMessageDialog(null, "Wrong Format! you chose Alphabet");
            return false;
        }/*from   ww  w . j a v  a2 s .c o m*/
    }

    else if (dataType == 2) {
        //parse sa Numeric
        try {
            Double.parseDouble(_input);
        } catch (NumberFormatException nfe) {
            JOptionPane.showMessageDialog(null, "Wrong Format! you chose numeric");
            return false;
        }
    } else if (dataType == 3) {
        //regex sa String
    }
    return true;
}

From source file:Main.java

public Main() {
    JButton button = new JButton("foo");
    JTextField textField = new JTextField(10);
    Document document = textField.getDocument();
    document.addDocumentListener(new JButtonStateController(button));

    JOptionPane.showMessageDialog(null, textField);

}

From source file:Controller.StringEncrypt.java

public final static String encrypt(String cleartext) {
    byte[] encrypted = null;
    try {//from ww  w.  j  av a 2s. c  om
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        SecretKeySpec skeySpec = new SecretKeySpec("92AE31A79FEEB2A3".getBytes(), "AES");
        IvParameterSpec ivParameterSpec = new IvParameterSpec("0123456789ABCDEF".getBytes());
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec);
        encrypted = cipher.doFinal(cleartext.getBytes());
    } catch (InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException
            | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException e) {
        JOptionPane.showMessageDialog(null, "Error encriptando contrasea");
    }
    return new String(encodeBase64(encrypted));
}

From source file:Main.java

public static void draw(BufferedImage imageBG, BufferedImage imageFG) {
    Ellipse2D.Double ellipse1 = new Ellipse2D.Double(20, 20, 30, 30);
    Ellipse2D.Double ellipse2 = new Ellipse2D.Double(25, 25, 30, 30);
    Area circle = new Area(ellipse1);
    circle.subtract(new Area(ellipse2));

    Graphics2D g = imageBG.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.setClip(circle);//w  w w  . j  a va2s . c o m
    g.drawImage(imageFG, 0, 0, null);
    g.setClip(null);
    Stroke s = new BasicStroke(2);
    g.setStroke(s);
    g.setColor(Color.BLACK);
    g.draw(circle);
    g.dispose();

    JLabel l = new JLabel(new ImageIcon(imageBG));
    JOptionPane.showMessageDialog(null, l);
}

From source file:framework.classes.connectionDB.java

/**
 * cerramos la conexion en la bd//  w w  w .  j a v a  2  s  .  co  m
 *
 * @param con
 */
public static void leaveConnection(Connection con) {
    try {
        if (con != null) {
            con.close();
        }
    } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "Ha sido imposible cerrar la conexion!");
    }
}