Example usage for javax.swing SwingUtilities getWindowAncestor

List of usage examples for javax.swing SwingUtilities getWindowAncestor

Introduction

In this page you can find the example usage for javax.swing SwingUtilities getWindowAncestor.

Prototype

public static Window getWindowAncestor(Component c) 

Source Link

Document

Returns the first Window ancestor of c, or null if c is not contained inside a Window.

Usage

From source file:savant.agp.HTTPBrowser.java

private void openIndexAs(int row, OpenAsOption opt) {
    try {// w w  w.  ja v a 2s. com
        String shortpath = ((HTTPTableModel) table.getModel()).getEntry(row);
        URI fullpath = new URI(getPath() + "/" + shortpath.replace("\\", "/"));

        File outputDir;
        String fileSeparator;
        String filename;

        switch (opt) {
        case TRACK:
            TrackUtils.createTrack(fullpath);
            break;
        case BOOKMARK:
            outputDir = DirectorySettings.getTmpDirectory();
            fileSeparator = System.getProperty("file.separator");
            filename = outputDir + fileSeparator + shortpath;
            if (!(new File(filename)).exists()) {
                // FIXME A Window is needed, I'm not sure that we can
                // actually get one this way
                DownloadDialog dd = new DownloadDialog(SwingUtilities.getWindowAncestor(this), true);
                dd.downloadFile(fullpath.toURL(), outputDir, null);
                setVisible(false);
            }
            BookmarkController.getInstance().addBookmarksFromFile(new File(filename), false);
            break;
        case DOCUMENT:
            outputDir = DirectorySettings.getTmpDirectory();
            fileSeparator = System.getProperty("file.separator");
            filename = outputDir + fileSeparator + shortpath;
            if (!(new File(filename)).exists()) {
                // FIXME A Window is needed, I'm not sure that we can
                // actually get one this way
                DownloadDialog dd = new DownloadDialog(SwingUtilities.getWindowAncestor(this), true);
                dd.downloadFile(fullpath.toURL(), outputDir, null);
                setVisible(false);
            }
            v.addDocument(filename);
            v.setExtendedState(v.getExtendedState() | DocumentViewer.MAXIMIZED_BOTH);
            v.setVisible(true);
            break;
        default:
            break;
        }
    } catch (Throwable x) {
        DialogUtils.displayException("AGP Plugin Error", "Unable to process request.", x);
    }
}

From source file:savant.view.swing.BookmarkSheet.java

private void loadBookmarks(JTable table) {
    final BookmarksTableModel btm = (BookmarksTableModel) table.getModel();
    List<Bookmark> bookmarks = btm.getData();

    if (bookmarks.size() > 0) {
        String message = "Clear existing bookmarks?";
        String title = "Clear Bookmarks";
        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION) {
            btm.clearData();/*from ww w. ja v a2  s.  co m*/
            BookmarkController.getInstance().clearBookmarks();
        }
    }

    final File selectedFile = DialogUtils.chooseFileForOpen("Load Bookmarks", null, null);

    // set the genome
    if (selectedFile != null) {

        int result = JOptionPane.showOptionDialog(null, "Would you like to add padding to each bookmark range?",
                "Add a margin?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
        final boolean addMargin = (result == JOptionPane.YES_OPTION);

        Window w = SwingUtilities.getWindowAncestor(BookmarkSheet.this);
        JOptionPane optionPane = new JOptionPane(
                "<html>Loading bookmarks from file.<br>This may take a moment.</html>",
                JOptionPane.INFORMATION_MESSAGE, JOptionPane.CANCEL_OPTION);
        final JDialog dialog = new JDialog(w, "Loading Bookmarks", Dialog.ModalityType.MODELESS);
        dialog.setContentPane(optionPane);
        dialog.pack();
        dialog.setLocationRelativeTo(w);
        dialog.setVisible(true);
        new Thread("BookmarkSheet.loadBookmarks") {
            @Override
            public void run() {
                try {
                    BookmarkController.getInstance().addBookmarksFromFile(selectedFile, addMargin);
                    btm.fireTableDataChanged();
                } catch (Exception ex) {
                    DialogUtils.displayError("Error", "Unable to load bookmarks: " + ex.getMessage());
                } finally {
                    dialog.setVisible(false);
                    dialog.dispose();
                }
            }
        }.start();
    }
}

From source file:ui.frame.UILogin.java

public UILogin() {
    super("Login");

    Label l = new Label();

    setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 300));

    Panel p = new Panel();

    loginPanel = p.createPanel(Layouts.grid, 4, 2);
    loginPanel.setBorder(new EmptyBorder(25, 25, 0, 25));
    lblUser = l.createLabel("Username:");
    lblPassword = l.createLabel("Password:");
    lblURL = l.createLabel("Server URL");
    lblBucket = l.createLabel("Bucket");

    tfURL = new JTextField();
    tfURL.setText("kaiup.kaisquare.com");
    tfBucket = new JTextField();
    PromptSupport.setPrompt("BucketName", tfBucket);
    tfUser = new JTextField();
    PromptSupport.setPrompt("Username", tfUser);
    pfPassword = new JPasswordField();
    PromptSupport.setPrompt("Password", pfPassword);

    buttonPanel = p.createPanel(Layouts.flow);
    buttonPanel.setBorder(new EmptyBorder(0, 0, 25, 0));
    Button b = new Button();
    JButton btnLogin = b.createButton("Login");
    JButton btnExit = b.createButton("Exit");
    btnLogin.setPreferredSize(new Dimension(150, 50));
    btnExit.setPreferredSize(new Dimension(150, 50));
    Component[] arrayBtn = { btnExit, btnLogin };
    p.addComponentsToPanel(buttonPanel, arrayBtn);

    Component[] arrayComponents = { lblURL, tfURL, lblBucket, tfBucket, lblUser, tfUser, lblPassword,
            pfPassword };/* w  w  w .  j a v  a2  s  . c o  m*/
    p.addComponentsToPanel(loginPanel, arrayComponents);
    add(loginPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    pack();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocationRelativeTo(null);

    setVisible(true);
    btnLogin.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    if (tfUser.getText().equals("") || String.valueOf(pfPassword.getPassword()).equals("")
                            || tfBucket.getText().equals("")) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please fill up all the fields", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        String username = tfUser.getText();
                        String password = String.valueOf(pfPassword.getPassword());
                        Data.URL = Data.protocol + tfURL.getText();
                        Data.targetURL = Data.protocol + tfURL.getText() + "/api/" + tfBucket.getText() + "/";

                        String response = api.loginBucket(Data.targetURL, username, password);

                        try {

                            if (DesktopAppMain.checkResult(response)) {
                                JSONObject responseJSON = new JSONObject(response);
                                Data.sessionKey = responseJSON.get("session-key").toString();
                                response = api.getUserFeatures(Data.targetURL, Data.sessionKey);
                                if (checkFeatures(response)) {
                                    Data.mainFrame = new KAIQRFrame();
                                    Data.mainFrame.uiInventorySelect = new UIInventorySelect();
                                    Data.mainFrame.addPanel(Data.mainFrame.uiInventorySelect, "inventory");
                                    Data.mainFrame.showPanel("inventory");
                                    Data.mainFrame.pack();
                                    setVisible(false);
                                    Data.mainFrame.setVisible(true);

                                } else {
                                    JOptionPane.showMessageDialog(Data.loginFrame,
                                            "User does not have necessary features", "Error",
                                            JOptionPane.ERROR_MESSAGE);
                                }
                            } else {
                                JOptionPane.showMessageDialog(Data.loginFrame, "Wrong username/password",
                                        "Error", JOptionPane.ERROR_MESSAGE);
                            }

                        } catch (JSONException e1) {
                            e1.printStackTrace();
                        }
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Login", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });

            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Logging in .........."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });

    btnExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }

    });

}

From source file:ui.panel.UIAccessKeySelect.java

public void runaccessKeySelect() {
    getAccessKeyData();/*from ww w.  j av a  2 s  . co  m*/
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Access Keys");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    Component[] BucketListComponents = { scrollBucket };
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);

    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnAdd = b.createButton("Generate Access Key");
    JButton btnRefresh = b.createButton("Refresh");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnAdd);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);

    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.showPanel("license");
        }
    });

    btnRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getAccessKeyData();
        }
    });
    btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.uiGenerateKey = new UIGenerateKey();
            Data.mainFrame.addPanel(Data.mainFrame.uiGenerateKey, "generateKey");
            Data.mainFrame.pack();
            Data.mainFrame.showPanel("generateKey");
        }
    });

    btnSelectElements.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    int selected = listBucket.getSelectedRow();

                    if (selected != -1) {
                        Data.accessKey = (String) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.qrGenerator = new JavaQR();
                        Data.mainFrame.pack();
                        Data.mainFrame.addPanel(Data.mainFrame.qrGenerator, "generateQR");
                        Data.mainFrame.showPanel("generateQR");
                    } else {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select Access Key", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Generating QR Code......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
}

From source file:ui.panel.UIBucketSelect.java

public void runBucketSelect() {
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Bucket List");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);//w  ww  .  ja  v  a2s  .co m

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    scrollBucket.setPreferredSize(new Dimension(300, 150));
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);
    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnRefresh = b.createButton("Refresh Bucket List");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);
    setVisible(true);

    btnRefresh.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            getBucketData();
        }
    });
    btnSelectElements.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {

                    int selected = listBucket.getSelectedRow();
                    if (selected == -1) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(),
                                "license");
                        Data.mainFrame.pack();
                        Data.mainFrame.showPanel("license");
                    }
                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving Licenses......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("inventory");
        }
    });
}

From source file:ui.panel.UILicenseAdd.java

public JPanel createButtonPanel() {
    JPanel panel = p.createPanel(Layouts.flow);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER));

    btnSubmit = b.createButton("Submit");
    btnCancel = b.createButton("Cancel");

    btnSubmit.addActionListener(new ActionListener() {

        @Override// w  ww .  java2 s.co  m
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    TreePath[] path = checkTreeManager.getSelectionModel().getSelectionPaths();
                    ArrayList<String> featureL = new ArrayList<String>();
                    String[] features = new String[] {};
                    for (TreePath tp : path) {

                        if (tp.getLastPathComponent().toString().equals("Features")) {
                            Object rootNode = tree.getModel().getRoot();
                            int parentCount = tree.getModel().getChildCount(rootNode);
                            for (int i = 0; i < parentCount; i++) {
                                Object parentNode = tree.getModel().getChild(rootNode, i);
                                int childrenCount = tree.getModel().getChildCount(parentNode);

                                for (int x = 0; x < childrenCount; x++) {
                                    MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x);
                                    featureL.add(node.getValue());
                                }
                            }
                        } else if (tp.getPathCount() == 2) {
                            Object rootNode = tree.getModel().getRoot();
                            int parentCount = tree.getModel().getChildCount(rootNode);
                            for (int i = 0; i < parentCount; i++) {
                                Object parentNode = tree.getModel().getChild(rootNode, i);
                                if (parentNode.toString().equals(tp.getLastPathComponent().toString())) {

                                    int childrenCount = tree.getModel().getChildCount(parentNode);

                                    for (int x = 0; x < childrenCount; x++) {
                                        MyDataNode node = (MyDataNode) tree.getModel().getChild(parentNode, x);
                                        featureL.add(node.getValue());
                                    }
                                }
                            }
                        } else if (tp.getPathCount() == 3) {
                            MyDataNode node = (MyDataNode) tp.getLastPathComponent();
                            featureL.add(node.getValue());
                        }

                    }
                    features = featureL.toArray(features);
                    String duration = spnValidity.getValue().toString();
                    if (cbPerpetual.isSelected()) {
                        duration = "-1";
                    }
                    String storage = spnCloud.getValue().toString();
                    String maxVCA = spnConcurrentVCA.getValue().toString();
                    String response = apiCall.addNodeLicense(Data.targetURL, Data.sessionKey, Data.bucketID,
                            features, duration, storage, maxVCA);

                    try {
                        JSONObject responseObject = new JSONObject(response);
                        if (responseObject.get("result").equals("ok")) {
                            Data.mainFrame.uiLicenseDetail.getLicenseData();
                            Data.mainFrame.showPanel("license");
                        }
                    } catch (JSONException e1) {
                        e1.printStackTrace();
                    }
                    return null;
                }
            };
            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving License..."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });

    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("license");
        }
    });

    panel.add(btnSubmit);
    panel.add(btnCancel);

    return panel;
}

From source file:ui.panel.UILicenseDetail.java

public JPanel createButtonPanel() {
    JPanel panel = p.createPanel(Layouts.flow);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER));

    btnSubmit = b.createButton("Next");
    btnBack = b.createButton("Back");
    btnAdd = b.createButton("Add License");

    panel.add(btnBack);//  ww w  .j a  v  a2 s . co m
    panel.add(btnAdd);
    panel.add(btnSubmit);
    btnBack.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.showPanel("bucket");
        }
    });

    btnAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd");
            Data.mainFrame.showPanel("licenseAdd");
        }
    });
    btnSubmit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    int row = tblInfo.getSelectedRow();
                    if (row == -1) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a License", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        Data.licenseNumber = (String) tblInfo.getModel().getValueAt(row, 0);
                        Data.mainFrame.uiAccessKeySelect = new UIAccessKeySelect();
                        Data.mainFrame.addPanel(Data.mainFrame.uiAccessKeySelect, "access");
                        Data.mainFrame.showPanel("access");
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving Access Keys"), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);

        }

    });

    btnBack.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("bucket");
        }
    });

    btnAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.addPanel(Data.mainFrame.uiLicenseAdd = new UILicenseAdd(), "licenseAdd");
            Data.mainFrame.pack();
            Data.mainFrame.showPanel("licenseAdd");
        }
    });

    return panel;
}

From source file:uk.ac.soton.mib104.t2.activities.json.ui.config.JSONPathConfigurationPanel.java

protected void initGui() {
    this.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    this.setLayout(new GridBagLayout());

    jsonPathAsTextField.setMinimumSize(new Dimension(240, jsonPathAsTextField.getMinimumSize().height));
    jsonPathAsTextField.setPreferredSize(jsonPathAsTextField.getMinimumSize());
    jsonPathAsTextField.setText("");

    jsonPathButton.addActionListener(new ActionListener() {

        @Override/*from w  w w. j  av  a  2s.c  om*/
        public void actionPerformed(final ActionEvent e) {
            final JSONPathInputDialog jsonPathInputDialog = new JSONPathInputDialog(
                    SwingUtilities.getWindowAncestor(JSONPathConfigurationPanel.this));

            final JSONPathInputPanel jsonPathInputPane = jsonPathInputDialog.getJSONPathInputPane();

            jsonPathInputPane.getJSONDocumentEditorPane().setText(jsonPathInputDialog_jsonPathEditorPane_text);

            jsonPathInputPane.getJsonPathEditorPane()
                    .setJSONValue(jsonPathInputDialog_jsonPathEditorPane_value);
            jsonPathInputPane.getJsonPathEditorPane()
                    .setTreeVisible(jsonPathInputDialog_jsonPathEditorPane_treeVisible);
            jsonPathInputPane.getJsonPathEditorPane().setText(jsonPathAsTextField.getText());

            jsonPathInputDialog.setVisible(true);

            switch (jsonPathInputDialog.getOption()) {
            case JOptionPane.OK_OPTION:
                break;
            default:
                return;
            }

            jsonPathInputDialog_jsonPathEditorPane_text = jsonPathInputPane.getJSONDocumentEditorPane()
                    .getText();
            jsonPathInputDialog_jsonPathEditorPane_treeVisible = jsonPathInputPane.getJsonPathEditorPane()
                    .isTreeVisible();
            jsonPathInputDialog_jsonPathEditorPane_value = jsonPathInputPane.getJsonPathEditorPane()
                    .getJSONValue();

            jsonPathAsTextField.setText(jsonPathInputPane.getJsonPathEditorPane().getText());
        }

    });
    jsonPathButton.setFont(jsonPathButton.getFont().deriveFont(11f));
    jsonPathButton.setIcon(JSONPathServiceIcon.getIcon());
    jsonPathButton.setText(jsonPathButtonText);
    jsonPathButton.setToolTipText(jsonPathButtonTip);

    final JLabel portDepthLabel = new JLabel();
    portDepthLabel.setFont(portDepthLabel.getFont().deriveFont(11f));
    portDepthLabel.setHorizontalAlignment(JLabel.LEFT);
    portDepthLabel.setIcon(Silk.getHelpIcon());
    portDepthLabel.setText(portDepthInputPaneText);
    portDepthLabel.setToolTipText(portDepthInputPaneTip);

    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;

    constraints.anchor = GridBagConstraints.WEST;
    this.add(JSONPathTextField.createLabelForDocument(jsonPathAsTextField.getDocument()), constraints);

    constraints.gridx++;

    constraints.anchor = GridBagConstraints.EAST;
    constraints.weightx = 1d;
    this.add(jsonPathAsTextField, constraints);
    constraints.weightx = 0;

    constraints.gridx++;

    constraints.fill = GridBagConstraints.NONE;
    this.add(jsonPathButton, constraints);

    constraints.gridx--;

    constraints.gridy++;

    constraints.anchor = GridBagConstraints.CENTER;
    this.add(JSONPathTextField.createLabelForDocumentationURI(), constraints);
    constraints.fill = GridBagConstraints.HORIZONTAL;

    constraints.gridx = 0;
    constraints.gridy++;

    constraints.gridwidth = 3;
    this.add(new JSeparator(JSeparator.HORIZONTAL), constraints);
    constraints.gridwidth = 1;

    constraints.gridx = 0;
    constraints.gridy++;

    constraints.anchor = GridBagConstraints.WEST;
    this.add(portDepthLabel, constraints);

    constraints.gridx++;

    constraints.anchor = GridBagConstraints.EAST;
    constraints.gridwidth = 2;
    this.add(portDepthInputPane, constraints);
    constraints.gridwidth = 1;
}

From source file:uk.chromis.pos.forms.JRootApp.java

public void tryToClose() {
    if (closeAppView()) {
        // success. continue with the shut down
        m_TP.getDeviceDisplay().clearVisor();
        session.close();/*from   ww w  .  j  a v a 2 s.co m*/
        // Download Root form
        SwingUtilities.getWindowAncestor(this).dispose();
    }
}

From source file:ve.zoonosis.controller.modulos.novdedades.NuevoClienteController.java

private void iniciarDialogo() {
    dialog = new MDialog((Dialog) SwingUtilities.getWindowAncestor(novedadController));
    dialog.setTitle("Nuevo");
    dialog.setResizable(false);//from   w w  w.j  a  va  2  s .c o m
    dialog.showPanel(this);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            cancelar();
        }
    });

}