Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType,
        Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException 

Source Link

Document

Prompts the user for input in a blocking dialog where the initial selection, possible selections, and all other options can be specified.

Usage

From source file:ru.apertum.qsystem.client.forms.FReception.java

@Action
public void changeStatusForPostponed() {
    if (listPostponed.getSelectedIndex() != -1) {
        final QCustomer cust = (QCustomer) listPostponed.getSelectedValue();

        String status = (String) JOptionPane.showInputDialog(this,
                getLocaleMessage("resultwork.dialog.caption"), getLocaleMessage("resultwork.dialog.title"),
                JOptionPane.QUESTION_MESSAGE, null, getResults(), null);
        if (status == null) {
            return;
        }/* w w  w.  j  av  a2  s  .  c om*/
        NetCommander.postponeCustomerChangeStatus(netProperty, cust.getId(), status);
        buttonRefreshPostponedActionPerformed(null);
    }
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

@Action
public void serviceDisable() {
    final TreePath selectedPath = treeServices.getSelectionPath();
    if (selectedPath != null) {
        final QService service = (QService) selectedPath.getLastPathComponent();
        final String name = (String) JOptionPane.showInputDialog(this,
                getLocaleMessage("admin.select_ability.message") + " \"" + service.getName() + "\"",
                getLocaleMessage("admin.select_ability.title"), JOptionPane.QUESTION_MESSAGE, null,
                new String[] { getLocaleMessage("admin.service_ability.yes"),
                        getLocaleMessage("admin.service_ability.no") },
                null);/*w w w. ja  v  a2  s.  co  m*/
        //?  ,  
        if (name != null) {
            if (name.equalsIgnoreCase(getLocaleMessage("admin.service_ability.yes"))) {
                NetCommander.changeTempAvailableService(netProperty, service.getId(), "");
            } else {
                final String mess = (String) JOptionPane.showInputDialog(this,
                        getLocaleMessage("admin.ability.enter_reason"),
                        getLocaleMessage("admin.select_ability.title"), JOptionPane.QUESTION_MESSAGE);
                if (mess != null) {
                    NetCommander.changeTempAvailableService(netProperty, service.getId(), mess);
                } else {
                    return;
                }
            }
            JOptionPane.showMessageDialog(this,
                    getLocaleMessage("admin.select_ability.message") + " " + service.getName() + " \"" + name
                            + "\"",
                    getLocaleMessage("admin.select_ability.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    }
}

From source file:streamme.visuals.Main.java

/**
 * Creates new form Main//  ww  w . ja  v a2  s .c  om
 */
public Main() {
    player = Player.getInstance();
    player.setListener(this);

    setIconImage(
            Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("res/icon32.png")));
    loadTray();

    hotkeyProvider = Provider.getCurrentProvider(false);
    hotkeyProvider.register(KeyStroke.getKeyStroke("alt UP"), new HotKeyListener() {
        public void onHotKey(HotKey hotKey) {
            btn_playPauseActionPerformed(null);
        }
    });
    hotkeyProvider.register(KeyStroke.getKeyStroke("alt RIGHT"), new HotKeyListener() {
        public void onHotKey(HotKey hotKey) {
            btn_nextActionPerformed(null);
        }
    });
    hotkeyProvider.register(KeyStroke.getKeyStroke("alt LEFT"), new HotKeyListener() {
        public void onHotKey(HotKey hotKey) {
            btn_prevActionPerformed(null);
        }
    });
    hotkeyProvider.register(KeyStroke.getKeyStroke("alt DOWN"), new HotKeyListener() {
        public void onHotKey(HotKey hotKey) {
            btn_stopActionPerformed(null);
        }
    });

    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Windows".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }

    initComponents();
    //getContentPane().setBackground(new java.awt.Color(123,161,214));
    PlaylistManager.get().setFrame(this);

    this.setLocationRelativeTo(null);

    treeMenu = new JPopupMenu();

    JMenuItem itemOpenToNew = new JMenuItem("Open to a new playlist");
    itemOpenToNew.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_files.getLastSelectedPathComponent();
            if (node == null)
                return;
            DataNode dn = (DataNode) node.getUserObject();
            int idx = PlaylistManager.get().addPlaylist(dn.getName());
            addToPlaylist(node, idx, true);
        }
    });

    JMenuItem itemAdd = new JMenuItem("Add to selected playlist...");
    itemAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_files.getLastSelectedPathComponent();
            if (node == null)
                return;
            addToPlaylist(node, playlistsPanel.getSelectedIndex(), true);
        }
    });

    treeMenu.add(itemOpenToNew);
    treeMenu.add(itemAdd);
    //tree_files.setComponentPopupMenu(menu);

    renamePlaylistKeyListener = new KeyListener() {
        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == 113) { // F2
                int idx = playlistsPanel.getSelectedIndex();
                if (idx < 0)
                    return;
                String oldTitle = playlistsPanel.getTitleAt(idx);
                String s = (String) JOptionPane.showInputDialog(Main.this, "Rename playlist:",
                        "Rename playlist", JOptionPane.PLAIN_MESSAGE, null, null, oldTitle);
                if (s != null) {
                    PlaylistManager.get().renameTab(idx, s);
                }
            }
        }
    };

    playlistsPanel.addKeyListener(renamePlaylistKeyListener);
}