check if user use windows or gnu/Linux using Swing JOptionPane - Java Swing

Java examples for Swing:JOptionPane

Description

check if user use windows or gnu/Linux using Swing JOptionPane

Demo Code


//package com.java2s;
import java.awt.Component;

import javax.swing.JOptionPane;

public class Main {
    /**//from  w  w w  . ja v  a2s  . c om
     * check if user use windows or gnu/Linux
     * @param compount to show the dialog
     * @return returns true if user clicked windows , false if clicked mac or gnu/linux
     */
    public static boolean initIsWindows(Component compount) {
        int result = JOptionPane.showOptionDialog(compount,
                "What is your operating System ?", "",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
                null, new String[] { "GNU/Linux or mac", "Windows" }, null);

        if (result == 0) {
            JOptionPane
                    .showMessageDialog(
                            compount,
                            "you must install mono to use this program "
                                    + "\n"
                                    + "in Gnu/linux : open terminal and type "
                                    + "\n"
                                    + "sudo apt-get install mono"
                                    + "\n"
                                    + "in mac : i don't know :D just search and you will find a way",
                            "", JOptionPane.WARNING_MESSAGE);
            return false;
        }

        else {
            JOptionPane.showMessageDialog(compount,
                    "You are good to go !!", "",
                    JOptionPane.INFORMATION_MESSAGE);
            return true;
        }
    }
}

Related Tutorials