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:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/style/download.png");

    final BufferedImage originalImage = ImageIO.read(url);
    int width = originalImage.getWidth();
    int height = originalImage.getHeight();
    final BufferedImage textImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = textImage.createGraphics();

    FontRenderContext frc = g.getFontRenderContext();
    Font font = new Font("Arial", Font.BOLD, 50);
    GlyphVector gv = font.createGlyphVector(frc, "java2s.com");

    int xOff = 0;
    int yOff = 50;

    Shape shape = gv.getOutline(xOff, yOff);
    g.setClip(shape);//ww  w . j av a 2  s  .c o  m
    g.drawImage(originalImage, 0, 0, null);

    g.setStroke(new BasicStroke(2f));
    g.setColor(Color.BLACK);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.draw(shape);
    g.dispose();

    ImageIO.write(textImage, "png", new File("cat-text.png"));

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(textImage)));
        }
    });
}

From source file:Examples.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Example Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));

    JFrame frame2 = new JFrame("Desktop");
    final JDesktopPane desktop = new JDesktopPane();
    frame2.getContentPane().add(desktop);
    JButton pick = new JButton("Pick");
    pick.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Hi");
        }// w w  w. j  a v  a2 s.c om
    });
    frame2.getContentPane().add(pick, BorderLayout.SOUTH);

    JButton messagePopup = new JButton("Message");
    contentPane.add(messagePopup);
    messagePopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showMessageDialog(source, "Printing complete");
            JOptionPane.showInternalMessageDialog(desktop, "Printing complete");
        }
    });

    JButton confirmPopup = new JButton("Confirm");
    contentPane.add(confirmPopup);
    confirmPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showConfirmDialog(source, "Continue printing?");
            JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?");
        }
    });

    JButton inputPopup = new JButton("Input");
    contentPane.add(inputPopup);
    inputPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showInputDialog(source, "Enter printer name:");
            // Moons of Neptune
            String smallList[] = { "Naiad", "Thalassa", "Despina", "Galatea", "Larissa", "Proteus", "Triton",
                    "Nereid" };
            JOptionPane.showInternalInputDialog(desktop, "Pick a printer", "Input",
                    JOptionPane.QUESTION_MESSAGE, null, smallList, "Triton");
            // Moons of Saturn - includes two provisional designations to
            // make 20
            String bigList[] = { "Pan", "Atlas", "Prometheus", "Pandora", "Epimetheus", "Janus", "Mimas",
                    "Enceladus", "Tethys", "Telesto", "Calypso", "Dione", "Helene", "Rhea", "Titan", "Hyperion",
                    "Iapetus", "Phoebe", "S/1995 S 2", "S/1981 S 18" };
            //        Object saturnMoon = JOptionPane.showInputDialog(source, "Pick
            // a printer", "Input", JOptionPane.QUESTION_MESSAGE, null,
            // bigList, "Titan");
            Object saturnMoon = JOptionPane.showInputDialog(source, "Pick a printer", "Input",
                    JOptionPane.QUESTION_MESSAGE, null, bigList, null);
            System.out.println("Saturn Moon: " + saturnMoon);
        }
    });

    JButton optionPopup = new JButton("Option");
    contentPane.add(optionPopup);
    optionPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();

            Icon greenIcon = new DiamondIcon(Color.green);
            Icon redIcon = new DiamondIcon(Color.red);
            Object iconArray[] = { greenIcon, redIcon };
            JOptionPane.showOptionDialog(source, "Continue printing?", "Select an Option",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]);

            Icon blueIcon = new DiamondIcon(Color.blue);
            Object stringArray[] = { "Do It", "No Way" };
            JOptionPane.showInternalOptionDialog(desktop, "Continue printing?", "Select an Option",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray,
                    stringArray[0]);
        }
    });

    frame.setSize(300, 200);
    frame.setVisible(true);
    frame2.setSize(300, 200);
    frame2.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    ScriptEngine engine = new ScriptEngineManager().getEngineByExtension("js");

    String[] ops = { "+", "-", "*", "/" };

    JPanel gui = new JPanel(new BorderLayout(2, 2));
    JPanel labels = new JPanel(new GridLayout(0, 1));
    gui.add(labels, BorderLayout.WEST);
    labels.add(new JLabel("a"));
    labels.add(new JLabel("operand"));
    labels.add(new JLabel("b"));
    labels.add(new JLabel("="));

    JPanel controls = new JPanel(new GridLayout(0, 1));
    gui.add(controls, BorderLayout.CENTER);
    JTextField a = new JTextField(10);
    controls.add(a);//from w  ww. ja  v a2s.  co  m
    JComboBox operand = new JComboBox(ops);
    controls.add(operand);
    JTextField b = new JTextField(10);
    controls.add(b);
    JTextField output = new JTextField(10);
    controls.add(output);

    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            String expression = a.getText() + operand.getSelectedItem() + b.getText();
            try {
                Object result = engine.eval(expression);
                if (result == null) {
                    output.setText("Output was 'null'");
                } else {
                    output.setText(result.toString());
                }
            } catch (ScriptException se) {
                output.setText(se.getMessage());
            }
        }
    };

    operand.addActionListener(al);
    a.addActionListener(al);
    b.addActionListener(al);

    JOptionPane.showMessageDialog(null, gui);
}

From source file:ffdammit.SkyProcMain.java

public static void main(String[] args) {
    try {//from ww  w . j  a v  a2s. co m
        SPGlobal.createGlobalLog();
        SUMGUI.open(new SkyProcMain(), args);
    } catch (Exception e) {
        // If a major error happens, print it everywhere and display a message box.
        System.err.println(e.toString());
        SPGlobal.logException(e);
        JOptionPane.showMessageDialog(null, "There was an exception thrown during program execution: '" + e
                + "'  Check the debug logs or contact the author.");
        SPGlobal.closeDebug();
    }
}

From source file:info.sugoiapps.xoclient.XOverClient.java

/**
 * @param args the command line arguments
 *///w  w w. java2 s .c  o m

public static void main(String[] args) {
    // System.getProperty("user.dir")); gets working directory in the form: C:\Users\Munyosz\etc...\
    final String SEPARATOR = " - ";
    XOverClient client = new XOverClient();
    String ladrs = getLocalAddress();
    if (client.validAddress(ladrs)) {
        MACHINE_IP = ladrs;

    } else {
        JOptionPane.showMessageDialog(null,
                "Your machine's internal IP couldn't be retreived, program will exit.");
        System.exit(0);
    }

    REMOTE_IP = null;
    if (!new File(CONFIG_FILENAME).exists()) {
        while (REMOTE_IP == null || REMOTE_IP.equalsIgnoreCase(""))
            REMOTE_IP = JOptionPane
                    .showInputDialog("Enter the internal IP of the machine you want to connect to.\n"
                            + "Must be in the format 192.168.xxx.xxx");
        String machinename = JOptionPane.showInputDialog("Now enter a name for the machine with internal IP "
                + "\"" + REMOTE_IP + "\"" + "\n"
                + "You will be able to select this machine from a list the next time you start the program.");
        new ListWriter(CONFIG_FILENAME).writeList(machinename + SEPARATOR + REMOTE_IP, APPEND);
    } else {
        MachineChooser mc = new MachineChooser(CONFIG_FILENAME, SEPARATOR, client);
        mc.setVisible(true);
        mc.setAddressInfo(MACHINE_IP);

        while (REMOTE_IP == null) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
                Logger.getLogger(XOverClient.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    new XOverClientGUI(REMOTE_IP, MACHINE_IP).setVisible(true);
    new FileServer().execute();
}

From source file:com.aan.girsang.client.launcher.ClientLauncher.java

public static void main(String[] args) throws Exception {

    BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
    org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
    UIManager.put("RootPane.setupButtonVisible", Boolean.FALSE);

    try {/*from   ww w.  j  av a 2  s  . c o m*/
        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("clientContext.xml");
        ctx.registerShutdownHook();

        constantService = (ConstantService) ctx.getBean("constantServiceRemote");
        securityService = (SecurityService) ctx.getBean("securityServiceRemote");
        masterService = (MasterService) ctx.getBean("masterServiceRemote");
        transaksiService = (TransaksiService) ctx.getBean("transaksiServiceRemote");
        reportService = (ReportService) ctx.getBean("reportServiceRemote");
        String computerName = InetAddress.getLocalHost().getHostName();

        constantService.clientOnline(computerName);
    } catch (RemoteConnectFailureException ex) {
        String status = "Server Offline";
        ex.printStackTrace();
        log.info(ex.getMessage());
        JOptionPane.showMessageDialog(null, status);
        System.exit(0);
    }
    log.info("Client Online");

    java.awt.EventQueue.invokeLater(() -> {
        FrameUtama fu = new FrameUtama();
        fu.setExtendedState(JFrame.MAXIMIZED_BOTH);
        fu.setVisible(true);
        fu.jam();
    });
}

From source file:gov.nih.nci.nbia.StandaloneDMDispatcher.java

/**
 * @param args/*from  w w w .jav  a 2  s  . c  om*/
 */
public static void main(String[] args) {
    if (args != null && (args.length > 0)) {
        String fileName = args[0];
        StandaloneDMDispatcher sdmp = new StandaloneDMDispatcher();
        sdmp.loadManifestFile(fileName);
        sdmp.launch();
    } else {
        JOptionPane.showMessageDialog(null, launchMsg);
        //System.exit(0);
    }
}

From source file:carolina.pegaLatLong.Teste.java

public static void main(String[] args) throws MalformedURLException, IOException, ParseException {
    List<InformacoesTxt> listaInfo = new ArrayList<InformacoesTxt>();
    //        String json = "";
    //        InputStream in = null;
    //      /*from www .  j  a v a2 s .  c  om*/
    //
    //        URL ul;
    //        
    //            ul = new URL("https://maps.googleapis.com/maps/api/geocode/json?address=10115,germany");
    //            HttpURLConnection conn = (HttpURLConnection) ul.openConnection();
    //           // conn.setRequestMethod("GET");
    //            //conn.setRequestProperty("Accept", "application/json");
    //            BufferedReader bf = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    //            String pega = "";
    //            String result = "";
    //            while((pega = bf.readLine()) != null){
    //                result+=pega;
    //            }
    //            System.err.println(result);
    //            
    //            org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
    //            Object obj = parser.parse(result);
    //            
    //            JSONObject tudo = (JSONObject) obj; 
    //            
    //            JSONArray jsonObject1 = (JSONArray) tudo.get("results");
    //            JSONObject jsonObject2 = (JSONObject)jsonObject1.get(0);
    //            JSONObject jsonObject3 = (JSONObject)jsonObject2.get("geometry");
    //            JSONObject location = (JSONObject) jsonObject3.get("location");
    //
    //            System.out.println( "Lat = "+location.get("lat"));
    //            System.out.println( "Lng = "+location.get("lng"));
    //
    //        String caminho = "externfiles\\emitente3.txt";
    //        FileInputStream file = new FileInputStream(caminho);
    //        InputStreamReader input = new InputStreamReader(file, java.nio.charset.StandardCharsets.ISO_8859_1);
    //        BufferedReader br = new BufferedReader(input);
    //        String pega = "";
    //        String mostra = "";
    //        System.err.println(mostra);
    //        int cont = 0;
    //        // Nome do Emitente,CNPJ,IE,Endereo,Bairro,CEP,Cidade,UF,Pais,
    //        while ((pega = br.readLine()) != null) {
    //            if (cont > 0) {
    //                String neew = LatLong.removerAcentos(pega.toLowerCase());
    //                String vet[] = neew.split(";");
    //                InformacoesTxt info = new InformacoesTxt();
    //                info.setEndereco(vet[0]);
    //                info.setCep(vet[2]);
    //                info.setBairro(vet[1]);
    //                info.setCidade(vet[3]);
    //                info.setUf(vet[4]);
    //                info.setPais(vet[5]);
    //                listaInfo.add(info);
    //            }
    //            cont++;
    //        }
    //
    //        //System.err.println("Tudo: " + cont);
    //        for (InformacoesTxt informacoes : listaInfo) {
    //
    //            System.out.println("Endereo: " + informacoes.getEndereco());
    //            System.out.println("Bairro: " + informacoes.getBairro());
    //            System.out.println("CEP: " + informacoes.getCep());
    //            System.out.println("Cidade: " + informacoes.getCidade());
    //            System.out.println("UF: " + informacoes.getUf());
    //            System.out.println("Pais: " + informacoes.getPais() + "\n");
    //
    //        }

    //        JPanel painel = new JPanel();
    //        JRadioButton btnEncontrados = new JRadioButton("Encontrados");
    //        JRadioButton btnNaoEncontrados = new JRadioButton("No encontrados");
    //        JRadioButton btnEncontradosMais = new JRadioButton("Mais de um encontrados");
    //        JRadioButton btnTudo = new JRadioButton("Tudo");
    //        ButtonGroup btnGroup = new ButtonGroup();
    //        btnGroup.add(btnTudo);
    //        btnGroup.add(btnEncontrados);
    //        btnGroup.add(btnNaoEncontrados);
    //        btnGroup.add(btnEncontradosMais);
    //
    //        painel.add(btnTudo);
    //        painel.add(btnEncontrados);
    //        painel.add(btnNaoEncontrados);
    //        painel.add(btnEncontradosMais);
    //        JOptionPane.showMessageDialog(null, painel);

    int a = 2;
    int b = 3;
    String teste = (a > b) ? "A maior que b" : "B maior que A";
    JOptionPane.showMessageDialog(null, teste);
}

From source file:me.timothy.ddd.DrunkDuckDispatch.java

License:asdf

public static void main(String[] args) throws LWJGLException {
    try {/*from   www . j  ava2  s  . c  o  m*/
        float defaultDisplayWidth = SizeScaleSystem.EXPECTED_WIDTH / 2;
        float defaultDisplayHeight = SizeScaleSystem.EXPECTED_HEIGHT / 2;
        boolean fullscreen = false, defaultDisplay = !fullscreen;
        File resolutionInfo = new File("graphics.json");

        if (resolutionInfo.exists()) {
            try (FileReader fr = new FileReader(resolutionInfo)) {
                JSONObject obj = (JSONObject) new JSONParser().parse(fr);
                Set<?> keys = obj.keySet();
                for (Object o : keys) {
                    if (o instanceof String) {
                        String key = (String) o;
                        switch (key.toLowerCase()) {
                        case "width":
                            defaultDisplayWidth = JSONCompatible.getFloat(obj, key);
                            break;
                        case "height":
                            defaultDisplayHeight = JSONCompatible.getFloat(obj, key);
                            break;
                        case "fullscreen":
                            fullscreen = JSONCompatible.getBoolean(obj, key);
                            defaultDisplay = !fullscreen;
                            break;
                        }
                    }
                }
            } catch (IOException | ParseException e) {
                e.printStackTrace();
            }
            float expHeight = defaultDisplayWidth
                    * (SizeScaleSystem.EXPECTED_HEIGHT / SizeScaleSystem.EXPECTED_WIDTH);
            float expWidth = defaultDisplayHeight
                    * (SizeScaleSystem.EXPECTED_WIDTH / SizeScaleSystem.EXPECTED_HEIGHT);
            if (Math.round(defaultDisplayWidth) != Math.round(expWidth)) {
                if (defaultDisplayHeight < expHeight) {
                    System.err.printf("%f x %f is an invalid resolution; adjusting to %f x %f\n",
                            defaultDisplayWidth, defaultDisplayHeight, defaultDisplayWidth, expHeight);
                    defaultDisplayHeight = expHeight;
                } else {
                    System.err.printf("%f x %f is an invalid resolution; adjusting to %f x %f\n",
                            defaultDisplayWidth, defaultDisplayHeight, expWidth, defaultDisplayHeight);
                    defaultDisplayWidth = expWidth;
                }
            }
        }
        File dir = null;
        String os = getOS();
        if (os.equals("windows")) {
            dir = new File(System.getenv("APPDATA"), "timgames/");
        } else {
            dir = new File(System.getProperty("user.home"), ".timgames/");
        }
        File lwjglDir = new File(dir, "lwjgl-2.9.1/");
        Resources.init();
        Resources.downloadIfNotExists(lwjglDir, "lwjgl-2.9.1.zip", "http://umad-barnyard.com/lwjgl-2.9.1.zip",
                "Necessary LWJGL natives couldn't be found, I can attempt "
                        + "to download it, but I make no promises",
                "Unfortunately I was unable to download it, so I'll open up the "
                        + "link to the official download. Make sure you get LWJGL version 2.9.1, "
                        + "and you put it at " + dir.getAbsolutePath() + "/lwjgl-2.9.1.zip",
                new Runnable() {

                    @Override
                    public void run() {
                        if (!Desktop.isDesktopSupported()) {
                            JOptionPane.showMessageDialog(null,
                                    "I couldn't " + "even do that! Download it manually and try again");
                            return;
                        }

                        try {
                            Desktop.getDesktop().browse(new URI("http://www.lwjgl.org/download.php"));
                        } catch (IOException | URISyntaxException e) {
                            JOptionPane.showMessageDialog(null,
                                    "Oh cmon.. Address is http://www.lwjgl.org/download.php, good luck");
                            System.exit(1);
                        }
                    }

                }, 5843626);

        Resources.extractIfNotFound(lwjglDir, "lwjgl-2.9.1.zip", "lwjgl-2.9.1");
        System.setProperty("org.lwjgl.librarypath",
                new File(dir, "lwjgl-2.9.1/lwjgl-2.9.1/native/" + os).getAbsolutePath()); // deal w/ it
        System.setProperty("net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath"));

        Resources.downloadIfNotExists("entities.json", "http://umad-barnyard.com/ddd/entities.json", 16142);
        Resources.downloadIfNotExists("map.binary", "http://umad-barnyard.com/ddd/map.binary", 16142);
        Resources.downloadIfNotExists("victory.txt", "http://umad-barnyard.com/ddd/victory.txt", 168);
        Resources.downloadIfNotExists("failure.txt", "http://umad-barnyard.com/ddd/failure.txt", 321);
        File resFolder = new File("resources/");
        if (!resFolder.exists() && !new File("player-still.png").exists()) {
            Resources.downloadIfNotExists("resources.zip", "http://umad-barnyard.com/ddd/resources.zip", 54484);
            Resources.extractIfNotFound(new File("."), "resources.zip", "player-still.png");
            new File("resources.zip").delete();
        }
        File soundFolder = new File("sounds/");
        if (!soundFolder.exists()) {
            soundFolder.mkdirs();
            Resources.downloadIfNotExists("sounds/sounds.zip", "http://umad-barnyard.com/ddd/sounds.zip",
                    1984977);
            Resources.extractIfNotFound(soundFolder, "sounds.zip", "asdfasdffadasdf");
            new File(soundFolder, "sounds.zip").delete();
        }
        AppGameContainer appgc;
        ddd = new DrunkDuckDispatch();
        appgc = new AppGameContainer(ddd);
        appgc.setTargetFrameRate(60);
        appgc.setShowFPS(false);
        appgc.setAlwaysRender(true);
        if (fullscreen) {
            DisplayMode[] modes = Display.getAvailableDisplayModes();
            DisplayMode current, best = null;
            float ratio = 0f;
            for (int i = 0; i < modes.length; i++) {
                current = modes[i];
                float rX = (float) current.getWidth() / SizeScaleSystem.EXPECTED_WIDTH;
                float rY = (float) current.getHeight() / SizeScaleSystem.EXPECTED_HEIGHT;
                System.out.println(current.getWidth() + "x" + current.getHeight() + " -> " + rX + "x" + rY);
                if (rX == rY && rX > ratio) {
                    best = current;
                    ratio = rX;
                }
            }
            if (best == null) {
                System.out.println("Failed to find an appropriately scaled resolution, using default display");
                defaultDisplay = true;
            } else {
                appgc.setDisplayMode(best.getWidth(), best.getHeight(), true);
                SizeScaleSystem.setRealHeight(best.getHeight());
                SizeScaleSystem.setRealWidth(best.getWidth());
                System.out.println("I choose " + best.getWidth() + "x" + best.getHeight());
            }
        }

        if (defaultDisplay) {
            SizeScaleSystem.setRealWidth(Math.round(defaultDisplayWidth));
            SizeScaleSystem.setRealHeight(Math.round(defaultDisplayHeight));
            appgc.setDisplayMode(Math.round(defaultDisplayWidth), Math.round(defaultDisplayHeight), false);
        }
        ddd.logger.info(
                "SizeScaleSystem: " + SizeScaleSystem.getRealWidth() + "x" + SizeScaleSystem.getRealHeight());
        appgc.start();
    } catch (SlickException ex) {
        LogManager.getLogger(DrunkDuckDispatch.class.getSimpleName()).catching(Level.ERROR, ex);
    }
}

From source file:de.mendelson.comm.as2.AS2.java

/**Method to start the server on from the command line*/
public static void main(String args[]) {

    // TODO remove
    cleanup();//  ww  w.  ja  v a 2 s  .c om

    String language = null;
    boolean startHTTP = true;
    boolean allowAllClients = false;
    int optind;
    for (optind = 0; optind < args.length; optind++) {
        if (args[optind].toLowerCase().equals("-lang")) {
            language = args[++optind];
        } else if (args[optind].toLowerCase().equals("-nohttpserver")) {
            startHTTP = false;
        } else if (args[optind].toLowerCase().equals("-allowallclients")) {
            allowAllClients = true;
        } else if (args[optind].toLowerCase().equals("-?")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-h")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-help")) {
            AS2.printUsage();
            System.exit(1);
        }
    }
    //load language from preferences
    if (language == null) {
        PreferencesAS2 preferences = new PreferencesAS2();
        language = preferences.get(PreferencesAS2.LANGUAGE);
    }
    if (language != null) {
        if (language.toLowerCase().equals("en")) {
            Locale.setDefault(Locale.ENGLISH);
        } else if (language.toLowerCase().equals("de")) {
            Locale.setDefault(Locale.GERMAN);
        } else if (language.toLowerCase().equals("fr")) {
            Locale.setDefault(Locale.FRENCH);
        } else {
            AS2.printUsage();
            System.out.println();
            System.out.println("Language " + language + " is not supported.");
            System.exit(1);
        }
    }
    Splash splash = new Splash("/de/mendelson/comm/as2/client/Splash.jpg");
    AffineTransform transform = new AffineTransform();
    splash.setTextAntiAliasing(false);
    transform.setToScale(1.0, 1.0);
    splash.addDisplayString(new Font("Verdana", Font.BOLD, 11), 7, 262, AS2ServerVersion.getFullProductName(),
            new Color(0x65, 0xB1, 0x80), transform);
    splash.setVisible(true);
    splash.toFront();
    //start server
    try {
        //register the database drivers for the VM
        Class.forName("org.hsqldb.jdbcDriver");
        //initialize the security provider
        BCCryptoHelper helper = new BCCryptoHelper();
        helper.initialize();
        AS2Server as2Server = new AS2Server(startHTTP, allowAllClients);
        AS2Agent agent = new AS2Agent(as2Server);
    } catch (UpgradeRequiredException e) {
        //an upgrade to HSQLDB 2.x is required, delete the lock file
        Logger.getLogger(AS2Server.SERVER_LOGGER_NAME).warning(e.getMessage());
        JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage());
        AS2Server.deleteLockFile();
        System.exit(1);
    } catch (Throwable e) {
        if (splash != null) {
            splash.destroy();
        }
        JOptionPane.showMessageDialog(null, e.getMessage());
        System.exit(1);
    }
    //start client
    AS2Gui gui = new AS2Gui(splash, "localhost");
    gui.setVisible(true);
    splash.destroy();
    splash.dispose();
}