Example usage for java.awt FlowLayout RIGHT

List of usage examples for java.awt FlowLayout RIGHT

Introduction

In this page you can find the example usage for java.awt FlowLayout RIGHT.

Prototype

int RIGHT

To view the source code for java.awt FlowLayout RIGHT.

Click Source Link

Document

This value indicates that each row of components should be right-justified.

Usage

From source file:org.tinymediamanager.ui.movies.dialogs.MovieBatchEditorDialog.java

/**
 * Instantiates a new movie batch editor.
 * //from w  w w.ja v a 2  s .  c o m
 * @param movies
 *          the movies
 */
public MovieBatchEditorDialog(final List<Movie> movies) {
    super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$
    setBounds(5, 5, 350, 230);
    getContentPane().setLayout(new BorderLayout(0, 0));

    {
        JPanel panelContent = new JPanel();
        getContentPane().add(panelContent, BorderLayout.CENTER);
        panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        panelContent.add(lblGenres, "2, 2, 2, 1, right, default");

        // cbGenres = new JComboBox(MediaGenres2.values());
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        panelContent.add(cbGenres, "5, 2, fill, default");

        JButton btnAddGenre = new JButton("");
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        btnAddGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = null;
                Object item = cbGenres.getSelectedItem();

                // genre
                if (item instanceof MediaGenres) {
                    genre = (MediaGenres) item;
                }

                // newly created genre?
                if (item instanceof String) {
                    genre = MediaGenres.getGenre((String) item);
                }
                // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem();
                if (genre != null) {
                    for (Movie movie : moviesToEdit) {
                        movie.addGenre(genre);
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddGenre, "7, 2");

        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeGenre(genre);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveGenre, "9, 2");

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        panelContent.add(lblTags, "2, 4, 2, 1, right, default");

        cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray());
        cbTags.setEditable(true);
        panelContent.add(cbTags, "5, 4, fill, default");

        JButton btnAddTag = new JButton("");
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                if (StringUtils.isBlank(tag)) {
                    return;
                }

                for (Movie movie : moviesToEdit) {
                    movie.addToTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddTag, "7, 4");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeFromTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveTag, "9, 4");

        JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
        panelContent.add(lblCertification, "2, 6, 2, 1, right, default");

        final JComboBox cbCertification = new JComboBox();
        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }
        panelContent.add(cbCertification, "5, 6, fill, default");

        JButton btnCertification = new JButton("");
        btnCertification.setMargin(new Insets(2, 2, 2, 2));
        btnCertification.setIcon(IconManager.APPLY);
        btnCertification.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Certification cert = (Certification) cbCertification.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.setCertification(cert);
                    ;
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnCertification, "7, 6");

        JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
        panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default");

        cbMovieSet = new JComboBox();
        panelContent.add(cbMovieSet, "5, 8, fill, default");

        JButton btnSetMovieSet = new JButton("");
        btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2));
        btnSetMovieSet.setIcon(IconManager.APPLY);
        btnSetMovieSet.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // movie set
                Object obj = cbMovieSet.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    if (obj instanceof String) {
                        movie.removeFromMovieSet();
                    }
                    if (obj instanceof MovieSet) {
                        MovieSet movieSet = (MovieSet) obj;

                        if (movie.getMovieSet() != movieSet) {
                            movie.removeFromMovieSet();
                            movie.setMovieSet(movieSet);
                            movieSet.insertMovie(movie);
                        }
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnSetMovieSet, "7, 8");

        JButton btnNewMovieset = new JButton("");
        btnNewMovieset.setMargin(new Insets(2, 2, 2, 2));
        btnNewMovieset.setAction(new MovieSetAddAction(false));
        panelContent.add(btnNewMovieset, "9, 8");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        panelContent.add(lblWatched, "2, 10, 2, 1, right, default");

        chckbxWatched = new JCheckBox("");
        panelContent.add(chckbxWatched, "5, 10");

        JButton btnWatched = new JButton("");
        btnWatched.setMargin(new Insets(2, 2, 2, 2));
        btnWatched.setIcon(IconManager.APPLY);
        btnWatched.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setWatched(chckbxWatched.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnWatched, "7, 10");

        JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
        panelContent.add(lblVideo3D, "2, 12, 2, 1, right, default");

        final JCheckBox chckbxVideo3D = new JCheckBox("");
        panelContent.add(chckbxVideo3D, "5, 12");

        JButton btnVideo3D = new JButton("");
        btnVideo3D.setMargin(new Insets(2, 2, 2, 2));
        btnVideo3D.setIcon(IconManager.APPLY);
        btnVideo3D.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setVideoIn3D(chckbxVideo3D.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnVideo3D, "7, 12");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        panelContent.add(lblMediasource, "2, 14, 2, 1, right, default");

        final JComboBox cbMediaSource = new JComboBox(MediaSource.values());
        panelContent.add(cbMediaSource, "5, 14, fill, default");

        JButton btnMediaSource = new JButton("");
        btnMediaSource.setMargin(new Insets(2, 2, 2, 2));
        btnMediaSource.setIcon(IconManager.APPLY);
        btnMediaSource.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                Object obj = cbMediaSource.getSelectedItem();
                if (obj instanceof MediaSource) {
                    MediaSource mediaSource = (MediaSource) obj;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setMediaSource(mediaSource);
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }
        });
        panelContent.add(btnMediaSource, "7, 14");

        JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$
        panelContent.add(lblLanguage, "2, 16, 2, 1, right, default");

        tfLanguage = new JTextField();
        panelContent.add(tfLanguage, "5, 16, fill, default");
        tfLanguage.setColumns(10);

        JButton btnLanguage = new JButton("");
        btnLanguage.setMargin(new Insets(2, 2, 2, 2));
        btnLanguage.setIcon(IconManager.APPLY);
        btnLanguage.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setSpokenLanguages(tfLanguage.getText());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnLanguage, "7, 16");
        {

            JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            panelContent.add(lblSorttitleT, "2, 18, right, default");

            JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$
            btnSetSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle(movie.getTitleSortable());
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });

            JLabel lblSorttitleInfo = new JLabel(IconManager.HINT);
            lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$
            panelContent.add(lblSorttitleInfo, "3, 18");
            panelContent.add(btnSetSorttitle, "5, 18");

            JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$
            btnClearSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle("");
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });
            panelContent.add(btnClearSorttitle, "5, 20");
        }
    }

    {
        JPanel panelButtons = new JPanel();
        FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout();
        flowLayout.setAlignment(FlowLayout.RIGHT);
        getContentPane().add(panelButtons, BorderLayout.SOUTH);

        JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$
        btnClose.setIcon(IconManager.APPLY);
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // rewrite movies, if anything changed
                if (changed) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
                setVisible(false);
            }
        });
        panelButtons.add(btnClose);

        // add window listener to write changes (if the window close button "X" is
        // pressed)
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // rewrite movies, if anything changed
                if (changed) {
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    // if configured - sync with trakt.tv
                    if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) {
                        TmmTask task = new SyncTraktTvTask(moviesToEdit, null);
                        TmmTaskManager.getInstance().addUnnamedTask(task);
                    }
                }
            }
        });
    }

    {
        setMovieSets();
        moviesToEdit = movies;

        PropertyChangeListener listener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("addedMovieSet".equals(evt.getPropertyName())) {
                    setMovieSets();
                }
            }
        };
        movieList.addPropertyChangeListener(listener);
    }
}

From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java

/**
 * createBagButtonPanel.//  w w w  .  j av  a2  s.  co m
 *
 * @return buttonPanel
 */
private JPanel createBagButtonPanel() {

    addDataHandler = new AddDataHandler(this);
    removeDataHandler = new RemoveDataHandler(this);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2));

    addDataToolBarAction = new JLabel("");
    addDataToolBarAction.setEnabled(false);
    addDataToolBarAction.setHorizontalAlignment(SwingConstants.CENTER);
    addDataToolBarAction.setBorder(new LineBorder(addDataToolBarAction.getBackground(), 1));
    addDataToolBarAction.setIcon(getPropertyImage("Bag_Content.add.icon"));
    addDataToolBarAction.setToolTipText(getMessage("bagView.payloadTree.addbutton.tooltip"));

    addDataToolBarAction.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            if (addDataToolBarAction.isEnabled()) {
                addDataHandler.actionPerformed(null);
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            addDataToolBarAction.setBorder(new LineBorder(addDataToolBarAction.getBackground(), 1));
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            if (addDataToolBarAction.isEnabled()) {
                addDataToolBarAction.setBorder(new LineBorder(Color.GRAY, 1));
            }
        }
    });
    buttonPanel.add(addDataToolBarAction);

    removeDataToolBarAction = new JLabel("");
    removeDataToolBarAction.setEnabled(false);
    removeDataToolBarAction.setHorizontalAlignment(SwingConstants.CENTER);
    removeDataToolBarAction.setBorder(new LineBorder(removeDataToolBarAction.getBackground(), 1));
    removeDataToolBarAction.setIcon(getPropertyImage("Bag_Content.minus.icon"));
    removeDataToolBarAction.setToolTipText(getMessage("bagView.payloadTree.remove.tooltip"));
    buttonPanel.add(removeDataToolBarAction);
    removeDataToolBarAction.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            if (removeDataToolBarAction.isEnabled()) {
                removeDataHandler.actionPerformed(null);
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            removeDataToolBarAction.setBorder(new LineBorder(removeDataToolBarAction.getBackground(), 1));
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            if (removeDataToolBarAction.isEnabled()) {
                removeDataToolBarAction.setBorder(new LineBorder(Color.GRAY, 1));
            }
        }
    });

    final JLabel spacerLabel = new JLabel("    ");
    buttonPanel.add(spacerLabel);

    addDataHandler = new AddDataHandler(this);
    removeDataHandler = new RemoveDataHandler(this);

    return buttonPanel;
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Creates a tab pane for the given GridJob.
 * //w  ww. j av a2 s .c o m
 * @param jobId JobId
 */
protected void createJobTab(final String jobId) {

    // Request Job Profile
    final InternalClusterJobService jobService = ClusterManager.getInstance().getJobService();
    final GridJobProfile profile = jobService.getProfile(jobId);

    // Job Start Time
    final long startTime = System.currentTimeMillis();

    final JPanel jobPanel = new JPanel();
    jobPanel.setLayout(new BorderLayout(10, 10));

    // Progess Panel
    JPanel progressPanel = new JPanel();
    progressPanel.setLayout(new BorderLayout(10, 10));
    progressPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
    jobPanel.add(progressPanel, BorderLayout.NORTH);

    final JProgressBar progressBar = new JProgressBar();
    progressBar.setStringPainted(true);
    progressPanel.add(progressBar, BorderLayout.CENTER);
    addUIElement("jobs." + jobId + ".progress", progressBar); // Add to components map

    // Buttons Panel
    JPanel buttonsPanel = new JPanel();
    jobPanel.add(buttonsPanel, BorderLayout.SOUTH);
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // Terminate Button
    JButton terminateButton = new JButton("Terminate");
    terminateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Thread(new Runnable() {

                public void run() {

                    // Job Name = Class Name
                    String name = profile.getJob().getClass().getSimpleName();

                    // Request user confirmation
                    int option = JOptionPane.showConfirmDialog(ClusterMainUI.this,
                            "Are you sure to terminate GridJob " + name + "?", "Nebula - Terminate GridJob",
                            JOptionPane.YES_NO_OPTION);

                    if (option == JOptionPane.NO_OPTION)
                        return;

                    // Attempt Cancel
                    boolean result = profile.getFuture().cancel();

                    // Notify results
                    if (result) {
                        JOptionPane.showMessageDialog(ClusterMainUI.this,
                                "Grid Job '" + name + "terminated successfully.", "Nebula - Job Terminated",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(ClusterMainUI.this,
                                "Failed to terminate Grid Job '" + name, "Nebula - Job Termination Failed",
                                JOptionPane.WARNING_MESSAGE);
                    }
                }

            }).start();
        }
    });
    buttonsPanel.add(terminateButton);
    addUIElement("jobs." + jobId + ".terminate", terminateButton); // Add to components map

    // Close Tab Button
    JButton closeButton = new JButton("Close Tab");
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    removeJobTab(jobId);
                }
            });
        }
    });
    closeButton.setEnabled(false);

    buttonsPanel.add(closeButton);
    addUIElement("jobs." + jobId + ".closetab", closeButton); // Add to components map

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridBagLayout());
    jobPanel.add(centerPanel, BorderLayout.CENTER);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weightx = 1.0;

    /* -- Job Information -- */

    JPanel jobInfoPanel = new JPanel();
    jobInfoPanel.setBorder(BorderFactory.createTitledBorder("Job Information"));
    jobInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 0;
    c.ipady = 30;
    centerPanel.add(jobInfoPanel, c);

    GridBagConstraints c1 = new GridBagConstraints();
    c1.fill = GridBagConstraints.BOTH;
    c1.weightx = 1;
    c1.weighty = 1;

    // Name
    jobInfoPanel.add(new JLabel("Name :"), c1);
    JLabel jobNameLabel = new JLabel();
    jobInfoPanel.add(jobNameLabel, c1);
    jobNameLabel.setText(profile.getJob().getClass().getSimpleName());
    addUIElement("jobs." + jobId + ".job.name", jobNameLabel); // Add to components map

    // Gap
    jobInfoPanel.add(new JLabel(), c1);

    // Type
    jobInfoPanel.add(new JLabel("Type :"), c1);
    JLabel jobType = new JLabel();
    jobType.setText(getJobType(profile.getJob()));
    jobInfoPanel.add(jobType, c1);
    addUIElement("jobs." + jobId + ".job.type", jobType); // Add to components map

    // Job Class Name
    c1.gridy = 1;
    c1.gridwidth = 1;
    jobInfoPanel.add(new JLabel("GridJob Class :"), c1);
    c1.gridwidth = GridBagConstraints.REMAINDER;
    JLabel jobClassLabel = new JLabel();
    jobClassLabel.setText(profile.getJob().getClass().getName());
    jobInfoPanel.add(jobClassLabel, c1);
    addUIElement("jobs." + jobId + ".job.class", jobClassLabel); // Add to components map

    /* -- Execution Information -- */

    JPanel executionInfoPanel = new JPanel();
    executionInfoPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics"));
    executionInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 1;
    c.ipady = 30;
    centerPanel.add(executionInfoPanel, c);

    GridBagConstraints c3 = new GridBagConstraints();
    c3.weightx = 1;
    c3.weighty = 1;
    c3.fill = GridBagConstraints.BOTH;

    // Start Time
    executionInfoPanel.add(new JLabel("Job Status :"), c3);
    final JLabel statusLabel = new JLabel("Initializing");
    executionInfoPanel.add(statusLabel, c3);
    addUIElement("jobs." + jobId + ".execution.status", statusLabel); // Add to components map

    // Status Update Listener
    profile.getFuture().addGridJobStateListener(new GridJobStateListener() {
        public void stateChanged(final GridJobState newState) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    statusLabel.setText(StringUtils.capitalize(newState.toString().toLowerCase()));
                }
            });
        }
    });

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Percent Complete
    executionInfoPanel.add(new JLabel("Completed % :"), c3);
    final JLabel percentLabel = new JLabel("-N/A-");
    executionInfoPanel.add(percentLabel, c3);
    addUIElement("jobs." + jobId + ".execution.percentage", percentLabel); // Add to components map

    c3.gridy = 1;

    // Start Time
    executionInfoPanel.add(new JLabel("Start Time :"), c3);
    JLabel startTimeLabel = new JLabel(DateFormat.getInstance().format(new Date(startTime)));
    executionInfoPanel.add(startTimeLabel, c3);
    addUIElement("jobs." + jobId + ".execution.starttime", startTimeLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Elapsed Time
    executionInfoPanel.add(new JLabel("Elapsed Time :"), c3);
    JLabel elapsedTimeLabel = new JLabel("-N/A-");
    executionInfoPanel.add(elapsedTimeLabel, c3);
    addUIElement("jobs." + jobId + ".execution.elapsedtime", elapsedTimeLabel); // Add to components map

    c3.gridy = 2;

    // Tasks Deployed (Count)
    executionInfoPanel.add(new JLabel("Tasks Deployed :"), c3);
    JLabel tasksDeployedLabel = new JLabel("-N/A-");
    executionInfoPanel.add(tasksDeployedLabel, c3);
    addUIElement("jobs." + jobId + ".execution.tasks", tasksDeployedLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Results Collected (Count)
    executionInfoPanel.add(new JLabel("Results Collected :"), c3);
    JLabel resultsCollectedLabel = new JLabel("-N/A-");
    executionInfoPanel.add(resultsCollectedLabel, c3);
    addUIElement("jobs." + jobId + ".execution.results", resultsCollectedLabel); // Add to components map

    c3.gridy = 3;

    // Remaining Tasks (Count)
    executionInfoPanel.add(new JLabel("Remaining Tasks :"), c3);
    JLabel remainingTasksLabel = new JLabel("-N/A-");
    executionInfoPanel.add(remainingTasksLabel, c3);
    addUIElement("jobs." + jobId + ".execution.remaining", remainingTasksLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Failed Tasks (Count)
    executionInfoPanel.add(new JLabel("Failed Tasks :"), c3);
    JLabel failedTasksLabel = new JLabel("-N/A-");
    executionInfoPanel.add(failedTasksLabel, c3);
    addUIElement("jobs." + jobId + ".execution.failed", failedTasksLabel); // Add to components map

    /* -- Submitter Information -- */
    UUID ownerId = profile.getOwner();
    GridNodeDelegate owner = ClusterManager.getInstance().getClusterRegistrationService()
            .getGridNodeDelegate(ownerId);

    JPanel ownerInfoPanel = new JPanel();
    ownerInfoPanel.setBorder(BorderFactory.createTitledBorder("Owner Information"));
    ownerInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 2;
    c.ipady = 10;
    centerPanel.add(ownerInfoPanel, c);

    GridBagConstraints c2 = new GridBagConstraints();

    c2.fill = GridBagConstraints.BOTH;
    c2.weightx = 1;
    c2.weighty = 1;

    // Host Name
    ownerInfoPanel.add(new JLabel("Host Name :"), c2);
    JLabel hostNameLabel = new JLabel(owner.getProfile().getName());
    ownerInfoPanel.add(hostNameLabel, c2);
    addUIElement("jobs." + jobId + ".owner.hostname", hostNameLabel); // Add to components map

    // Gap
    ownerInfoPanel.add(new JLabel(), c2);

    // Host IP Address
    ownerInfoPanel.add(new JLabel("Host IP :"), c2);
    JLabel hostIPLabel = new JLabel(owner.getProfile().getIpAddress());
    ownerInfoPanel.add(hostIPLabel, c2);
    addUIElement("jobs." + jobId + ".owner.hostip", hostIPLabel); // Add to components map

    // Owner UUID
    c2.gridy = 1;
    c2.gridx = 0;
    ownerInfoPanel.add(new JLabel("Owner ID :"), c2);
    JLabel ownerIdLabel = new JLabel(profile.getOwner().toString());
    c2.gridx = 1;
    c2.gridwidth = 4;
    ownerInfoPanel.add(ownerIdLabel, c2);
    addUIElement("jobs." + jobId + ".owner.id", ownerIdLabel); // Add to components map

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            // Create Tab
            addUIElement("jobs." + jobId, jobPanel);
            JTabbedPane tabs = getUIElement("tabs");
            tabs.addTab(profile.getJob().getClass().getSimpleName(), jobPanel);
            tabs.revalidate();
        }
    });

    // Execution Information Updater Thread
    new Thread(new Runnable() {

        boolean initialized = false;
        boolean unbounded = false;

        public void run() {

            // Unbounded, No Progress Supported
            if ((!initialized) && profile.getJob() instanceof UnboundedGridJob<?>) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        progressBar.setIndeterminate(true);
                        progressBar.setStringPainted(false);

                        // Infinity Symbol
                        percentLabel.setText(String.valueOf('\u221e'));

                    }
                });
                initialized = true;
                unbounded = true;
            }

            // Update Job Info
            while (true) {

                try {
                    // 500ms Interval
                    Thread.sleep(500);

                } catch (InterruptedException e) {
                    log.warn("Interrupted Progress Updater Thread", e);
                }

                final int totalCount = profile.getTotalTasks();
                final int tasksRem = profile.getTaskCount();
                final int resCount = profile.getResultCount();
                final int failCount = profile.getFailedCount();

                showBusyIcon();

                // Task Information
                JLabel totalTaskLabel = getUIElement("jobs." + jobId + ".execution.tasks");
                totalTaskLabel.setText(String.valueOf(totalCount));

                // Result Count
                JLabel resCountLabel = getUIElement("jobs." + jobId + ".execution.results");
                resCountLabel.setText(String.valueOf(resCount));

                // Remaining Task Count
                JLabel remLabel = getUIElement("jobs." + jobId + ".execution.remaining");
                remLabel.setText(String.valueOf(tasksRem));

                // Failed Task Count
                JLabel failedLabel = getUIElement("jobs." + jobId + ".execution.failed");
                failedLabel.setText(String.valueOf(failCount));

                // Elapsed Time
                JLabel elapsedLabel = getUIElement("jobs." + jobId + ".execution.elapsedtime");
                elapsedLabel.setText(TimeUtils.timeDifference(startTime));

                // Job State
                final JLabel statusLabel = getUIElement("jobs." + jobId + ".execution.status");

                // If not in Executing Mode
                if ((!profile.getFuture().isJobFinished())
                        && profile.getFuture().getState() != GridJobState.EXECUTING) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {

                            // Progress Bar
                            progressBar.setIndeterminate(true);
                            progressBar.setStringPainted(false);

                            // Status Text
                            String state = profile.getFuture().getState().toString();
                            statusLabel.setText(StringUtils.capitalize(state.toLowerCase()));

                            // Percentage Label
                            percentLabel.setText(String.valueOf('\u221e'));
                        }
                    });
                } else { // Executing Mode : Progress Information

                    // Job Finished, Stop
                    if (profile.getFuture().isJobFinished()) {
                        showIdleIcon();
                        return;
                    }

                    // Double check for status label
                    if (!statusLabel.getText().equalsIgnoreCase("executing")) {
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                String newstate = profile.getFuture().getState().toString();
                                statusLabel.setText(StringUtils.capitalize(newstate.toLowerCase()));
                            }

                        });
                    }

                    if (!unbounded) {

                        final int percentage = (int) (profile.percentage() * 100);

                        //final int failCount = profile.get
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {

                                // If finished at this point, do not update
                                if (progressBar.getValue() == 100) {
                                    return;
                                }

                                // If ProgressBar is in indeterminate
                                if (progressBar.isIndeterminate()) {
                                    progressBar.setIndeterminate(false);
                                    progressBar.setStringPainted(true);
                                }

                                // Update Progress Bar / Percent Label
                                progressBar.setValue(percentage);
                                percentLabel.setText(percentage + " %");

                            }
                        });
                    }
                }

            }
        }
    }).start();

    // Job End Hook to Execute Job End Actions
    ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {

        public void onServiceEvent(final ServiceMessage event) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {

                    JButton close = getUIElement("jobs." + jobId + ".closetab");
                    JButton terminate = getUIElement("jobs." + jobId + ".terminate");
                    terminate.setEnabled(false);
                    close.setEnabled(true);

                    JProgressBar progress = getUIElement("jobs." + jobId + ".progress");
                    JLabel percentage = getUIElement("jobs." + jobId + ".execution.percentage");

                    progress.setEnabled(false);

                    // If Successfully Finished
                    if (event.getType() == ServiceMessageType.JOB_END) {

                        if (profile.getFuture().getState() != GridJobState.FAILED) {
                            // If Not Job Failed
                            progress.setValue(100);
                            percentage.setText("100 %");
                        } else {
                            // If Failed
                            percentage.setText("N/A");
                        }

                        // Stop (if) Indeterminate Progress Bar
                        if (progress.isIndeterminate()) {
                            progress.setIndeterminate(false);
                            progress.setStringPainted(true);
                        }
                    } else if (event.getType() == ServiceMessageType.JOB_CANCEL) {

                        if (progress.isIndeterminate()) {
                            progress.setIndeterminate(false);
                            progress.setStringPainted(false);
                            percentage.setText("N/A");
                        }
                    }

                    showIdleIcon();
                }
            });
        }

    }, jobId, ServiceMessageType.JOB_CANCEL, ServiceMessageType.JOB_END);
}

From source file:edu.harvard.mcz.imagecapture.GeoreferenceDialog.java

private void init() {
    setBounds(100, 100, 450, 560);/* w ww  .j  av  a 2  s  .co  m*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new GridLayout(0, 2, 0, 0));
    {
        JLabel lblLatitude = new JLabel("Latitude");
        lblLatitude.setHorizontalAlignment(SwingConstants.RIGHT);
        contentPanel.add(lblLatitude);
    }

    textFieldDecimalLat = new JTextField();
    contentPanel.add(textFieldDecimalLat);
    textFieldDecimalLat.setColumns(10);

    JLabel lblLongitude = new JLabel("Longitude");
    lblLongitude.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongitude);
    {
        textFieldDecimalLong = new JTextField();
        contentPanel.add(textFieldDecimalLong);
        textFieldDecimalLong.setColumns(10);
    }
    {
        JLabel lblDatum = new JLabel("Datum");
        lblDatum.setHorizontalAlignment(SwingConstants.RIGHT);
        contentPanel.add(lblDatum);
    }

    @SuppressWarnings("unchecked")
    ComboBoxModel<String> datumModel = new ListComboBoxModel<String>(LatLong.getDatumValues());
    cbDatum = new JComboBox<String>(datumModel);
    contentPanel.add(cbDatum);

    JLabel lblMethod = new JLabel("Method");
    lblMethod.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblMethod);

    @SuppressWarnings("unchecked")
    ComboBoxModel<String> methodModel = new ListComboBoxModel<String>(LatLong.getGeorefMethodValues());
    cbMethod = new JComboBox<String>(new DefaultComboBoxModel<String>(new String[] { "not recorded", "unknown",
            "GEOLocate", "Google Earth", "Gazeteer", "GPS", "MaNIS/HertNet/ORNIS Georeferencing Guidelines" }));
    cbMethod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setState();
        }
    });
    contentPanel.add(cbMethod);

    JLabel lblAccuracy = new JLabel("GPS Accuracy");
    lblAccuracy.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblAccuracy);

    txtGPSAccuracy = new JTextField();
    txtGPSAccuracy.setColumns(10);
    contentPanel.add(txtGPSAccuracy);

    JLabel lblNewLabel_1 = new JLabel("Original Units");
    lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblNewLabel_1);

    comboBoxOrigUnits = new JComboBox<String>();
    comboBoxOrigUnits.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setState();
        }
    });
    comboBoxOrigUnits.setModel(new DefaultComboBoxModel<String>(
            new String[] { "decimal degrees", "deg. min. sec.", "degrees dec. minutes", "unknown" }));
    contentPanel.add(comboBoxOrigUnits);

    lblErrorRadius = new JLabel("Error Radius");
    lblErrorRadius.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblErrorRadius);

    txtErrorRadius = new JTextField();
    txtErrorRadius.setColumns(10);
    contentPanel.add(txtErrorRadius);

    JLabel lblErrorRadiusUnits = new JLabel("Error Radius Units");
    lblErrorRadiusUnits.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblErrorRadiusUnits);

    comboBoxErrorUnits = new JComboBox<String>();
    comboBoxErrorUnits.setModel(new DefaultComboBoxModel<String>(new String[] { "m", "ft", "km", "mi", "yd" }));
    contentPanel.add(comboBoxErrorUnits);

    JLabel lblLatDegrees = new JLabel("Lat Degrees");
    lblLatDegrees.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDegrees);

    txtLatDegrees = new JTextField();
    txtLatDegrees.setColumns(4);
    contentPanel.add(txtLatDegrees);

    JLabel lblLatDecMin = new JLabel("Lat Dec Min");
    lblLatDecMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDecMin);

    txtLatDecMin = new JTextField();
    txtLatDecMin.setColumns(6);
    contentPanel.add(txtLatDecMin);

    JLabel lblLatMin = new JLabel("Lat Min");
    lblLatMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatMin);

    txtLatMin = new JTextField();
    txtLatMin.setColumns(6);
    contentPanel.add(txtLatMin);

    JLabel lblLatSec = new JLabel("Lat Sec");
    lblLatSec.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatSec);

    txtLatSec = new JTextField();
    txtLatSec.setColumns(6);
    contentPanel.add(txtLatSec);

    JLabel lblLatDir = new JLabel("Lat N/S");
    lblLatDir.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLatDir);

    cbLatDir = new JComboBox<String>();
    cbLatDir.setModel(new DefaultComboBoxModel<String>(new String[] { "N", "S" }));
    contentPanel.add(cbLatDir);

    JLabel lblLongDegrees = new JLabel("Long Degrees");
    lblLongDegrees.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDegrees);

    txtLongDegrees = new JTextField();
    txtLongDegrees.setColumns(4);
    contentPanel.add(txtLongDegrees);

    JLabel lblLongDecMin = new JLabel("Long Dec Min");
    lblLongDecMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDecMin);

    txtLongDecMin = new JTextField();
    txtLongDecMin.setColumns(6);
    contentPanel.add(txtLongDecMin);

    JLabel lblLongMin = new JLabel("Long Min");
    lblLongMin.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongMin);

    txtLongMin = new JTextField();
    txtLongMin.setColumns(6);
    contentPanel.add(txtLongMin);

    JLabel lblLongSec = new JLabel("Long Sec");
    lblLongSec.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongSec);

    txtLongSec = new JTextField();
    txtLongSec.setColumns(6);
    contentPanel.add(txtLongSec);

    JLabel lblLongDir = new JLabel("Long E/W");
    lblLongDir.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblLongDir);

    cbLongDir = new JComboBox<String>();
    cbLongDir.setModel(new DefaultComboBoxModel<String>(new String[] { "E", "W" }));
    contentPanel.add(cbLongDir);

    JLabel lblDetBy = new JLabel("Determined By");
    lblDetBy.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblDetBy);

    textFieldDetBy = new JTextField();
    contentPanel.add(textFieldDetBy);
    textFieldDetBy.setColumns(10);

    JLabel lblDetDate = new JLabel("Date Determined");
    lblDetDate.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblDetDate);

    try {
        textDetDate = new JFormattedTextField(new MaskFormatter("####-##-##"));
    } catch (ParseException e1) {
        textDetDate = new JFormattedTextField();
    }
    textDetDate.setToolTipText("Date on which georeference was made yyyy-mm-dd");
    contentPanel.add(textDetDate);

    JLabel lblRef = new JLabel("Reference Source");
    lblRef.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblRef);

    textRefSource = new JTextField();
    contentPanel.add(textRefSource);
    textRefSource.setColumns(10);

    lblNewLabel = new JLabel("Remarks");
    lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(lblNewLabel);

    textFieldRemarks = new JTextField();
    contentPanel.add(textFieldRemarks);
    textFieldRemarks.setColumns(10);

    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            lblErrorLabel = new JLabel("Message");
            buttonPane.add(lblErrorLabel);
        }
        {
            okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    lblErrorLabel.setText("");

                    if (saveData()) {
                        setVisible(false);
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    loadData();
                    setVisible(false);
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java

/**
 * createBagTagButtonPanel.//from w w w .j  a  v a  2s  .c  o m
 *
 * @return buttonPanel
 */
private JPanel createBagTagButtonPanel() {

    final JPanel buttonPanel = new JPanel();

    final ShowTagFilesHandler showTageFileHandler = new ShowTagFilesHandler(this);
    addTagFileHandler = new AddTagFileHandler(this);
    removeTagFileHandler = new RemoveTagFileHandler(this);

    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2));

    viewTagFilesToolbarAction = new JLabel("");
    viewTagFilesToolbarAction.setEnabled(false);
    viewTagFilesToolbarAction.setHorizontalAlignment(SwingConstants.CENTER);
    viewTagFilesToolbarAction.setBorder(new LineBorder(viewTagFilesToolbarAction.getBackground(), 1));
    viewTagFilesToolbarAction.setIcon(getPropertyImage("Bag_ViewTagFile.icon"));
    viewTagFilesToolbarAction.setToolTipText(getMessage("bagView.TagFilesTree.viewfile" + ".tooltip"));

    viewTagFilesToolbarAction.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            if (viewTagFilesToolbarAction.isEnabled()) {
                showTageFileHandler.actionPerformed(null);
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            viewTagFilesToolbarAction.setBorder(new LineBorder(viewTagFilesToolbarAction.getBackground(), 1));
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            if (viewTagFilesToolbarAction.isEnabled()) {
                viewTagFilesToolbarAction.setBorder(new LineBorder(Color.GRAY, 1));
            }
        }
    });
    buttonPanel.add(viewTagFilesToolbarAction);

    addTagFileToolBarAction = new JLabel("");
    addTagFileToolBarAction.setEnabled(false);
    addTagFileToolBarAction.setHorizontalAlignment(SwingConstants.CENTER);
    addTagFileToolBarAction.setBorder(new LineBorder(addTagFileToolBarAction.getBackground(), 1));
    addTagFileToolBarAction.setIcon(getPropertyImage("Bag_Content.add.icon"));
    addTagFileToolBarAction.setToolTipText(getMessage("bagView.TagFilesTree.addbutton" + ".tooltip"));

    addTagFileToolBarAction.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            if (addTagFileToolBarAction.isEnabled()) {
                addTagFileHandler.actionPerformed(null);
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            addTagFileToolBarAction.setBorder(new LineBorder(addTagFileToolBarAction.getBackground(), 1));
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            if (addTagFileToolBarAction.isEnabled()) {
                addTagFileToolBarAction.setBorder(new LineBorder(Color.GRAY, 1));
            }
        }
    });
    buttonPanel.add(addTagFileToolBarAction);

    removeTagFileToolbarAction = new JLabel("");
    removeTagFileToolbarAction.setEnabled(false);
    removeTagFileToolbarAction.setHorizontalAlignment(SwingConstants.CENTER);
    removeTagFileToolbarAction.setBorder(new LineBorder(removeTagFileToolbarAction.getBackground(), 1));
    removeTagFileToolbarAction.setIcon(getPropertyImage("Bag_Content.minus.icon"));
    removeTagFileToolbarAction.setToolTipText(getMessage("bagView.TagFilesTree.remove" + ".tooltip"));

    buttonPanel.add(removeTagFileToolbarAction);
    removeTagFileToolbarAction.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            if (removeTagFileToolbarAction.isEnabled()) {
                removeTagFileHandler.actionPerformed(null);
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            removeTagFileToolbarAction.setBorder(new LineBorder(removeTagFileToolbarAction.getBackground(), 1));
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            if (removeTagFileToolbarAction.isEnabled()) {
                removeTagFileToolbarAction.setBorder(new LineBorder(Color.GRAY, 1));
            }
        }
    });

    final JLabel spacerLabel = new JLabel("    ");
    buttonPanel.add(spacerLabel);

    addTagFileHandler = new AddTagFileHandler(this);
    removeTagFileHandler = new RemoveTagFileHandler(this);

    return buttonPanel;
}

From source file:com.sshtools.shift.FileTransferDialog.java

private void jbInit() throws Exception {

    getContentPane().setLayout(new BorderLayout());

    progressbar.setToolTipText("");

    progressbar.setValue(0);//from  w ww .  j  a  v a 2  s . com

    try {

        Method m = progressbar.getClass().getMethod("setIndeterminate", new Class[] { boolean.class });

        Object[] args = new Object[] {

                new Boolean(true) };

        m.invoke(progressbar, args);

    }

    catch (Throwable ex) {

    }

    //progressbar.setIndeterminate(true);

    progressbar.setBounds(new Rectangle(8, 45, 336, 22));

    lblEstimatedTime.setText("Estimated time left: ");

    lblEstimatedTime.setBounds(new Rectangle(8, 74, 114, 17));

    lblTimeLeftValue.setText("");

    lblTimeLeftValue.setBounds(new Rectangle(109, 74, 235, 17));

    lblTargetAction.setText("Downloading to:");

    lblTargetAction.setBounds(new Rectangle(8, 92, 96, 17));

    lblTargetValue.setText("");

    lblTargetValue.setBounds(new Rectangle(109, 92, 235, 17));

    lblTransferRate.setText("Transfer rate: ");

    lblTransferRate.setBounds(new Rectangle(8, 110, 96, 17));

    lblTransferRateValue.setText("");

    lblTransferRateValue.setBounds(new Rectangle(109, 110, 235, 17));

    btnCancel.setText("Cancel");

    btnCancel.addActionListener(new FileTransferDialog_cancel_actionAdapter(

            this));

    chkClose.setText("Close this window when the transfer completes");

    chkClose.setBounds(new Rectangle(8, 132, 307, 18));

    chkClose.setSelected(true);

    JPanel p = new JPanel(null);

    lblAction.setBounds(new Rectangle(9, 5, 334, 21));

    lblPathValue.setText("");

    lblPathValue.setBounds(new Rectangle(10, 22, 329, 22));

    p.add(progressbar);

    p.add(lblEstimatedTime);

    p.add(lblTimeLeftValue);

    p.add(lblTargetAction);

    p.add(lblTransferRate);

    p.add(lblTransferRateValue);

    p.add(lblTargetValue);

    p.add(lblAction);

    p.add(lblPathValue);

    p.add(chkClose);

    JPanel b = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    b.add(btnCancel);

    p.setMaximumSize(new Dimension(350, 185));

    p.setMinimumSize(new Dimension(350, 185));

    p.setPreferredSize(new Dimension(350, 185));

    getContentPane().add(p, BorderLayout.CENTER);

    getContentPane().add(b, BorderLayout.SOUTH);

    elaspedTime = 0;

    formatMb.setMaximumFractionDigits(2);

    formatKb.setMaximumFractionDigits(0);

    formatKb1.setMaximumFractionDigits(1);

    setResizable(true);

    setSize(new Dimension(350, 184));

    UIUtil.positionComponent(UIUtil.CENTER, this);

}

From source file:userinterface.graph.Histogram.java

/**
 * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram
 * to plot data on/*  w ww.ja  va 2  s.  c om*/
 * 
 * @param defaultSeriesName
 * @param handler instance of {@link GUIGraphHandler}
 * @param minVal the min value in data cache
 * @param maxVal the max value in data cache
 * @return Either a new instance of a Histogram or an old one depending on what the user selects
 */

public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler,
        double minVal, double maxVal) {

    // make sure that the probabilities are valid
    if (maxVal > 1.0)
        maxVal = 1.0;
    if (minVal < 0.0)
        minVal = 0.0;

    // set properties for the dialog
    JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true);
    dialog.setLayout(new BorderLayout());

    JPanel p1 = new JPanel(new FlowLayout());
    p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Number of buckets"));

    JPanel p2 = new JPanel(new FlowLayout());
    p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Series name"));

    JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1));
    buckets.setToolTipText("Select the number of buckets for this Histogram");

    // provides the ability to select a new or an old histogram to plot the series on
    JTextField seriesName = new JTextField(defaultSeriesName);
    JRadioButton newSeries = new JRadioButton("New Histogram");
    JRadioButton existing = new JRadioButton("Existing Histogram");
    newSeries.setSelected(true);
    JPanel seriesSelectPanel = new JPanel();
    seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS));
    JPanel seriesTypeSelect = new JPanel(new FlowLayout());
    JPanel seriesOptionsPanel = new JPanel(new FlowLayout());
    seriesTypeSelect.add(newSeries);
    seriesTypeSelect.add(existing);
    JComboBox<String> seriesOptions = new JComboBox<>();
    seriesOptionsPanel.add(seriesOptions);
    seriesSelectPanel.add(seriesTypeSelect);
    seriesSelectPanel.add(seriesOptionsPanel);
    seriesSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to"));

    // provides ability to select the min/max range of the plot
    JLabel minValsLabel = new JLabel("Min range:");
    JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01));
    minVals.setToolTipText("Does not allow value more than the min value in the probabilities");
    JLabel maxValsLabel = new JLabel("Max range:");
    JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01));
    maxVals.setToolTipText("Does not allow value less than the max value in the probabilities");
    JPanel minMaxPanel = new JPanel();
    minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS));
    JPanel leftValsPanel = new JPanel(new BorderLayout());
    JPanel rightValsPanel = new JPanel(new BorderLayout());
    minMaxPanel.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range"));
    leftValsPanel.add(minValsLabel, BorderLayout.WEST);
    leftValsPanel.add(minVals, BorderLayout.CENTER);
    rightValsPanel.add(maxValsLabel, BorderLayout.WEST);
    rightValsPanel.add(maxVals, BorderLayout.CENTER);
    minMaxPanel.add(leftValsPanel);
    minMaxPanel.add(rightValsPanel);

    // fill the old histograms in the property dialog

    boolean found = false;
    for (int i = 0; i < handler.getNumModels(); i++) {

        if (handler.getModel(i) instanceof Histogram) {

            seriesOptions.addItem(handler.getGraphName(i));
            found = true;
        }

    }

    existing.setEnabled(found);
    seriesOptions.setEnabled(false);

    // the bottom panel
    JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton ok = new JButton("Plot");
    JButton cancel = new JButton("Cancel");

    // bind keyboard keys to plot and cancel buttons to improve usability

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = -7324877661936685228L;

        @Override
        public void actionPerformed(ActionEvent e) {

            ok.doClick();

        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ok");
    cancel.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = 2642213543774356676L;

        @Override
        public void actionPerformed(ActionEvent e) {

            cancel.doClick();

        }
    });

    //Action listener for the new series radio button
    newSeries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (newSeries.isSelected()) {

                existing.setSelected(false);
                seriesOptions.setEnabled(false);
                buckets.setEnabled(true);
                buckets.setToolTipText("Select the number of buckets for this Histogram");
                minVals.setEnabled(true);
                maxVals.setEnabled(true);
            }
        }
    });

    //Action listener for the existing series radio button
    existing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existing.isSelected()) {

                newSeries.setSelected(false);
                seriesOptions.setEnabled(true);
                buckets.setEnabled(false);
                minVals.setEnabled(false);
                maxVals.setEnabled(false);
                buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram");
            }

        }
    });

    //Action listener for the plot button
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            dialog.dispose();

            if (newSeries.isSelected()) {

                hist = new Histogram();
                hist.setNumOfBuckets((int) buckets.getValue());
                hist.setIsNew(true);

            } else if (existing.isSelected()) {

                String HistName = (String) seriesOptions.getSelectedItem();
                hist = (Histogram) handler.getModel(HistName);
                hist.setIsNew(false);

            }

            key = hist.addSeries(seriesName.getText());

            if (minVals.isEnabled() && maxVals.isEnabled()) {

                hist.setMinProb((double) minVals.getValue());
                hist.setMaxProb((double) maxVals.getValue());

            }
        }
    });

    //Action listener for the cancel button
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
            hist = null;
        }
    });

    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {

            hist = null;
        }
    });

    p1.add(buckets, BorderLayout.CENTER);

    p2.add(seriesName, BorderLayout.CENTER);

    options.add(ok);
    options.add(cancel);

    // add everything to the main panel of the dialog
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(seriesSelectPanel);
    mainPanel.add(p1);
    mainPanel.add(p2);
    mainPanel.add(minMaxPanel);

    // add main panel to the dialog
    dialog.add(mainPanel, BorderLayout.CENTER);
    dialog.add(options, BorderLayout.SOUTH);

    // set dialog properties
    dialog.setSize(320, 290);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setVisible(true);

    // return the user selected Histogram with the properties set
    return new Pair<Histogram, SeriesKey>(hist, key);
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private JPanel getJPanel6() {
    if (jPanel6 == null) {
        jPanel6 = new JPanel();
        FlowLayout jPanel6Layout = new FlowLayout();
        jPanel6Layout.setAlignment(FlowLayout.RIGHT);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6.add(getJlblLink());//w w  w.j  a v a 2s.c  o  m
    }
    return jPanel6;
}

From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java

/**
 * Creates a panel containing all dialog control buttons, like close, load, save and import.
 *
 * @return the button panel.//  ww  w  .  ja v a 2 s .c o m
 */
private JPanel createButtonPane() {
    final Action closeAction = new CloseAction();
    final Action saveAction = new SaveAction();
    final Action loadAction = new LoadAction();
    final Action importAction = new ImportAction();

    final JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    panel.setBorder(new EmptyBorder(5, 5, 5, 5));

    final JPanel buttonHolder = new JPanel();
    buttonHolder.setLayout(new GridLayout(1, 4, 5, 5));
    buttonHolder.add(new JButton(importAction));
    buttonHolder.add(new JButton(loadAction));
    buttonHolder.add(new JButton(saveAction));
    buttonHolder.add(new JButton(closeAction));

    panel.add(buttonHolder);
    return panel;
}

From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java

/**
 * Creates the detail editor panel. This panel will contain all specific editors for the keys.
 *
 * @return the detail editor panel./*w  w  w .j  ava 2  s  .  c om*/
 */
private JPanel createEditPane() {

    final JPanel buttonHolder = new JPanel();
    buttonHolder.setLayout(new GridLayout(1, 4, 5, 5));
    buttonHolder.add(new JButton(new CancelAction()));
    buttonHolder.add(new JButton(new UpdateAction()));

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    buttonPanel.add(buttonHolder);

    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(createDetailEditorPanel(), BorderLayout.CENTER);
    panel.add(buttonPanel, BorderLayout.SOUTH);
    return panel;
}