List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException
From source file:Main.java
CountUpProgressBar() { super.setLayout(new GridLayout(0, 1)); bar.setValue(0);//www . ja v a 2s . c o m timer.start(); this.add(bar); this.add(label); JOptionPane.showMessageDialog(null, this); }
From source file:BareBonesBrowserLaunch.java
public static void openURL(String url) { String osName = System.getProperty("os.name"); try {//from ww w . j a va 2 s . com if (osName.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class }); openURL.invoke(null, new Object[] { url }); } else if (osName.startsWith("Windows")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { //assume Unix or Linux String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser"); else Runtime.getRuntime().exec(new String[] { browser, url }); } } catch (Exception e) { JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage()); } }
From source file:Main.java
Main() { shapes.add(new Ellipse2D.Double(10, 10, 20, 30)); MouseAdapter listener = new MouseAdapter() { @Override/*ww w . j ava 2s. c om*/ public void mouseClicked(MouseEvent me) { mouse = me.getPoint(); drawImage(); } }; l.addMouseListener(listener); drawImage(); JOptionPane.showMessageDialog(null, l); }
From source file:BrowserLauncher.java
public static void openURL(String url) { int os = PlatformDetector.detect(); try {/*w w w .j ava 2 s . co m*/ if (os == PlatformDetector.MACOS) { Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils"); Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] { String.class }); openURL.invoke(null, new Object[] { url }); } else if (os == PlatformDetector.WINDOWS) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { // assume Unix or Linux String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser."); else Runtime.getRuntime().exec(new String[] { browser, url }); } } catch (Exception e) { JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage()); } }
From source file:SysTray.java
public void installSystemTray() throws Exception { PopupMenu menu = new PopupMenu(); MenuItem exit = new MenuItem("Exit"); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0);/*from ww w.j av a2 s . c om*/ } }); menu.add(exit); TrayIcon icon = new TrayIcon(getImage(), "Java application as a tray icon", menu); icon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Hi!"); } }); SystemTray.getSystemTray().add(icon); Thread.sleep(3000); icon.displayMessage("Attention", "Please click here", TrayIcon.MessageType.WARNING); }
From source file:Classes.DBConnection.java
/** * Opens a connection to database//from w ww . j a va2 s . co m * @return a connection to database */ public Connection OpenConnection() { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); String urlOdbc = "jdbc:mysql://127.0.0.1:3306/prog"; con = (Connection) (java.sql.DriverManager.getConnection(urlOdbc, "root", "12345")); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Ha sido imposible establecer la conexion!"); } return con; }
From source file:Main.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == b) { if (i == 0) { JOptionPane.showMessageDialog(null, "This is First Image"); } else {//from ww w . jav a2s .c o m i = i - 1; l.setIcon(m[i]); } } if (e.getSource() == b1) { if (i == m.length - 1) { JOptionPane.showMessageDialog(null, "This is LastImage"); } else { i = i + 1; l.setIcon(m[i]); } } }
From source file:Model.OpMenu.java
public void Cadastro_Cliente(Cliente cliente) { client.LeArquivo();//from w ww . ja v a2 s.c o m if (client.BuscaCliente(cliente.getNome()) == null) { client.Add(cliente); client.SalvaArquivo(cliente); JOptionPane.showMessageDialog(null, "Cliente Cadastrado com sucesso"); } else JOptionPane.showMessageDialog(null, "Cliente j cadastrado"); }
From source file:classes.connectionPool.java
public static void start_BasicDataSourceFactory() { Properties propiedades = new Properties(); /*//from w ww . ja v a2 s . c o m setMaxActive(): N mx de conexiones que se pueden abrir simultneamente. setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms. setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando. */ propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver"); propiedades.setProperty("url", "jdbc:mysql://127.0.0.1:3306/bbdd_admin"); propiedades.setProperty("maxActive", "10"); propiedades.setProperty("maxIdle", "8"); propiedades.setProperty("minIdle", "0"); propiedades.setProperty("maxWait", "500"); propiedades.setProperty("initialSize", "5"); propiedades.setProperty("defaultAutoCommit", "true"); propiedades.setProperty("username", "root"); propiedades.setProperty("password", ""); propiedades.setProperty("validationQuery", "select 1"); propiedades.setProperty("validationQueryTimeout", "100"); propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2"); propiedades.setProperty("poolPreparedStatements", "true"); propiedades.setProperty("maxOpenPreparedStatements", "10"); try { dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } }
From source file:framework.clss.ConnectionBD.java
/** * Open conection with Data Base// ww w.j a v a2 s .co m * */ public static void inicializa_BasicDataSourceFactory() { Properties propiedades = new Properties(); /* setMaxActive(): N mx de conexiones que se pueden abrir simultneamente. setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms. setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando. */ propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver"); propiedades.setProperty("url", "jdbc:mysql://localhost:3306/mysql"); propiedades.setProperty("maxActive", "10"); propiedades.setProperty("maxIdle", "8"); propiedades.setProperty("minIdle", "0"); propiedades.setProperty("maxWait", "500"); propiedades.setProperty("initialSize", "5"); propiedades.setProperty("defaultAutoCommit", "true"); propiedades.setProperty("username", "root"); propiedades.setProperty("password", ""); propiedades.setProperty("validationQuery", "select 1"); propiedades.setProperty("validationQueryTimeout", "100"); propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2"); propiedades.setProperty("poolPreparedStatements", "true"); propiedades.setProperty("maxOpenPreparedStatements", "10"); try { //propiedades.load(new FileInputStream("src/config/datasource_config.properties")); dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } }