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

public static void main(String[] args) throws Exception {
    if (!SystemTray.isSupported()) {
        System.out.println("SystemTray is not supported");
        return;//from   w w  w .j  a v a  2s  . co m
    }

    SystemTray tray = SystemTray.getSystemTray();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage("trayIcon.jpg");

    PopupMenu menu = new PopupMenu();

    MenuItem messageItem = new MenuItem("Show Message");
    messageItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "www.java2s.com");
        }
    });
    menu.add(messageItem);

    MenuItem closeItem = new MenuItem("Close");
    closeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    menu.add(closeItem);
    TrayIcon icon = new TrayIcon(image, "SystemTray Demo", menu);
    icon.setImageAutoSize(true);

    tray.add(icon);
}

From source file:classTest.fileTest.java

public static void main(String args[]) throws IOException {
    hbaseDB connHB = new hbaseDB("/Users/andresbenitez/Documents/app/ABTViewer3/srvConf.properties", "HBConf2");

    FileSystem hdfs = org.apache.hadoop.fs.FileSystem.get(connHB.getHcfg());

    JOptionPane.showMessageDialog(null, hdfs.getHomeDirectory().toString());

    JOptionPane.showMessageDialog(null, hdfs.getWorkingDirectory());

    hdfs.setWorkingDirectory(new Path("hdfs://hortonserver.com:8020/user/guest/"));

    System.out.println(hdfs.getWorkingDirectory().toString());

    String dirName = "TestDirectory";
    Path destPath = new Path(
            "hdfs://hortonserver.e-contact.cl:8020/user/guest/20160413_000118_00011008887674_98458726_TTR42-1460516478.154581.WAV");
    Path sr1 = new Path("hdfs://hortonserver.com:8020/user/guest/Test");

    //hdfs.mkdirs(sr1);

    //FileSystem lhdfs = LocalFileSystem.get(hbconf);

    //System.out.println(lhdfs.getWorkingDirectory().toString());
    //System.out.println(hdfs.getWorkingDirectory().toString());

    //Path sourcePath = new Path("/Users/andresbenitez/Documents/Apps/test.txt");

    //Path destPath = new Path("/Users/andresbenitez/Documents/Apps/test4.txt");

    //hdfs.copyFromLocalFile(sourcePath, destPath);

    //hdfs.copyToLocalFile(false, new Path("hdfs://sandbox.hortonworks.com:8020/user/guest/installupload.log"), new Path("/Users/andresbenitez/Documents/instaldown3.log"), true);

    //hdfs.copyToLocalFile(false, new Path("/Users/andresbenitez/Documents/instaldown.log"), new Path("hdfs://sandbox.hortonworks.com:8020/user/guest/installupload.log"), false);

    //File f=new File("http://srv-gui-g.e-contact.cl/e-recorder/audio/20160413/08/01_20160413_084721_90010990790034__1460548041.4646.wav");
    URL url = new URL(
            "http://grabacionesclaro.e-contact.cl/2011/2016041300/20160413_000118_00011008887674_98458726_TTR42-1460516478.154581.WAV");

    File filePaso = new File("/Users/andresbenitez/Documents/paso/JOJOJO.WAV");

    File f2 = new File(
            "/grabacionesclaro.e-contact.cl/2011/2016041300/20160413_000118_00011008887674_98458726_TTR42-1460516478.154581.WAV");

    org.apache.commons.io.FileUtils.copyURLToFile(url, filePaso);

    //org.apache.commons.io.FileUtils.copyFile(f2, filePaso);

    //&hdfs.copyToLocalFile(false, new Path("/Users/andresbenitez/Documents/paso/JOJOJO.mp3"), destPath);

    //hdfs.copyFromLocalFile(false, new Path("/Users/andresbenitez/Documents/paso/JOJOJO.WAV"), destPath);

}

From source file:Main.java

public static void main(String[] args) {
    String[][] data = { { "Data", "Data" } };
    String[] col = { "Col", "Col" };
    final DefaultTableModel model = new DefaultTableModel(data, col);
    JTable table = new JTable(model);
    JButton addRow = new JButton("Add Empty Row");
    addRow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model.addRow(new Object[] {});
        }/*w  w  w  . ja  v  a  2s. c  o m*/
    });
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JScrollPane(table));
    panel.add(addRow, BorderLayout.SOUTH);
    JOptionPane.showMessageDialog(null, panel);
}

From source file:Main.java

public static void main(String[] args) {
    JScrollPane sPane = new JScrollPane();
    sPane.setPreferredSize(new Dimension(200, 150));
    JButton button = new JButton(new AbstractAction("Create Table") {
        public void actionPerformed(ActionEvent arg0) {
            DefaultTableModel model = new DefaultTableModel(new Integer[][] { { 1, 2 }, { 3, 4 } },
                    new String[] { "A", "B" });
            JTable table = new JTable(model);
            sPane.getViewport().add(table);
        }//from w  ww  . j av a  2 s. c  o  m
    });
    JPanel panel = new JPanel();
    panel.add(sPane);
    panel.add(button);
    JOptionPane.showMessageDialog(null, panel);

}

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 image = ImageIO.read(url);
    int x = 50;/*from  w w w. ja v  a2s.c om*/
    final Image crop = image.getSubimage(x, 0, image.getWidth() - x, image.getHeight());
    Runnable r = new Runnable() {
        @Override
        public void run() {
            JPanel gui = new JPanel();
            gui.add(new JLabel(new ImageIcon(image)), BorderLayout.LINE_START);
            gui.add(new JLabel("java2s.com"));
            gui.add(new JLabel(new ImageIcon(crop)), BorderLayout.LINE_END);
            JOptionPane.showMessageDialog(null, gui);
        }
    };
    SwingUtilities.invokeLater(r);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new XorFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new GrayFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:JapaneseCalendar.java

public static void main(String[] args) {
    Locale japanese = new Locale("ja", "JP", "JP");

    Calendar cal = Calendar.getInstance(japanese);
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, japanese);
    String str = df.format(cal.getTime());

    JOptionPane.showMessageDialog(null, str);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new RedBlueSwapFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:com.aan.girsang.server.launcher.ServerLauncher.java

public static void main(String[] args) {
    try {/*ww  w . java 2 s  . c o  m*/
        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
                new String[] { "applicationContext.xml", "serverContext.xml" });
        ctx.registerShutdownHook();
        log.info("SERVER ONLINE");
    } catch (BeanCreationException bce) {
        JOptionPane.showMessageDialog(null, "Server Sudah Aktif");
        bce.printStackTrace();
    }

}