Example usage for javax.swing JProgressBar JProgressBar

List of usage examples for javax.swing JProgressBar JProgressBar

Introduction

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

Prototype

public JProgressBar(int min, int max) 

Source Link

Document

Creates a horizontal progress bar with the specified minimum and maximum.

Usage

From source file:org.pentaho.reporting.libraries.designtime.swing.background.WaitDialog.java

private void init() {
    logger.debug("Initializing the Wait Dialog");
    setModal(true);//w  w w  .j  a v a 2s .co m
    setTitle(Messages.getInstance().getString("WaitDialog.TITLE"));

    message = new JLabel(Messages.getInstance().getString("WaitDialog.MESSAGE"));
    progressBar = new JProgressBar(0, 1000);

    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(PADDING, PADDING));
    setContentPane(contentPane);
}

From source file:org.rdv.ui.ExportVideoDialog.java

private void initComponents() {

    JPanel container = new JPanel();
    setContentPane(container);//from  w w w .j av a  2  s . c  o  m

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Select the time range and video channels to export.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    JPanel timeButtonPanel = new JPanel();
    timeButtonPanel.setLayout(new BorderLayout());

    MouseListener hoverMouseListener = new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            e.getComponent().setForeground(Color.red);
        }

        public void mouseExited(MouseEvent e) {
            e.getComponent().setForeground(Color.blue);
        }
    };

    startTimeButton = new JButton();
    startTimeButton.setBorder(null);
    startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    startTimeButton.setForeground(Color.blue);
    startTimeButton.addMouseListener(hoverMouseListener);
    startTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double startTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getStart(),
                    timeSlider.getMinimum(), timeSlider.getEnd());
            if (startTime >= 0) {
                timeSlider.setStart(startTime);
            }
        }
    });
    timeButtonPanel.add(startTimeButton, BorderLayout.WEST);

    durationLabel = new JLabel();
    durationLabel.setHorizontalAlignment(JLabel.CENTER);
    timeButtonPanel.add(durationLabel, BorderLayout.CENTER);

    endTimeButton = new JButton();
    endTimeButton.setBorder(null);
    endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    endTimeButton.setForeground(Color.blue);
    endTimeButton.addMouseListener(hoverMouseListener);
    endTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double endTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getEnd(),
                    timeSlider.getStart(), timeSlider.getMaximum());
            if (endTime >= 0) {
                timeSlider.setEnd(endTime);
            }
        }
    });
    timeButtonPanel.add(endTimeButton, BorderLayout.EAST);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 10);
    container.add(timeButtonPanel, c);

    timeSlider = new TimeSlider();
    timeSlider.setValueChangeable(false);
    timeSlider.setValueVisible(false);
    timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() {
        public void timeChanged(TimeEvent event) {
        }

        public void rangeChanged(TimeEvent event) {
            updateTimeRangeLabel();
        }

        public void boundsChanged(TimeEvent event) {
        }
    });
    updateTimeRangeLabel();
    updateTimeBounds();

    List<EventMarker> markers = rbnb.getMarkerManager().getMarkers();
    for (EventMarker marker : markers) {
        timeSlider.addMarker(marker);
    }

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(timeSlider, c);

    JLabel numericHeaderLabel = new JLabel("Video Channels:");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(numericHeaderLabel, c);

    videoChannelList = new JList(videoChannelModel);
    videoChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    videoChannelList.setCellRenderer(new CheckListRenderer());
    videoChannelList.setVisibleRowCount(10);
    videoChannelList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            int index = videoChannelList.locationToIndex(e.getPoint());
            ExportChannel item = (ExportChannel) videoChannelList.getModel().getElementAt(index);
            item.setSelected(!item.isSelected());
            Rectangle rect = videoChannelList.getCellBounds(index, index);
            videoChannelList.repaint(rect);

            updateTimeBounds();
        }
    });
    JScrollPane scrollPane = new JScrollPane(videoChannelList);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(scrollPane, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("Choose Directory: "), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    directoryTextField = new JTextField(20);
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(directoryTextField, c);

    directoryTextField.setText(UIUtilities.getCurrentDirectory().getAbsolutePath());
    directoryButton = new JButton("Browse");
    directoryButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            File selectedDirectory = UIUtilities.getDirectory("Select export directory");
            if (selectedDirectory != null) {
                directoryTextField.setText(selectedDirectory.getAbsolutePath());
            }
        }
    });
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 2;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(directoryButton, c);

    exportProgressBar = new JProgressBar(0, 100000);
    exportProgressBar.setStringPainted(true);
    exportProgressBar.setValue(0);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(exportProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action exportAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 1547500154252213911L;

        public void actionPerformed(ActionEvent e) {
            exportVideo();
        }
    };
    exportAction.putValue(Action.NAME, "Export");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export");
    actionMap.put("export", exportAction);
    exportButton = new JButton(exportAction);
    panel.add(exportButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -7440298547807878651L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();
    if (getWidth() < 600) {
        setSize(600, getHeight());
    }

    directoryTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

From source file:org.rdv.ui.ImportDialog.java

private void initComponents() {
    JPanel container = new JPanel();
    setContentPane(container);/*from ww  w.j a  v a  2s.  co m*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Please specify the desired source name for the data.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 5);
    container.add(new JLabel("Source name: "), c);

    sourceNameTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(10, 0, 10, 10);
    container.add(sourceNameTextField, c);

    importProgressBar = new JProgressBar(0, 100000);
    importProgressBar.setStringPainted(true);
    importProgressBar.setValue(0);
    importProgressBar.setVisible(false);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(importProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action importAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -4719316285523193555L;

        public void actionPerformed(ActionEvent e) {
            importData();
        }
    };
    importAction.putValue(Action.NAME, "Import");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import");
    actionMap.put("export", importAction);
    importButton = new JButton(importAction);
    getRootPane().setDefaultButton(importButton);
    panel.add(importButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 7909429022904810958L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();

    sourceNameTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

From source file:org.zaproxy.zap.extension.bruteforce.BruteForcePanel.java

private JProgressBar getProgressBar() {
    if (progressBar == null) {
        progressBar = new JProgressBar(0, 100); // Max will change as scan progresses
        progressBar.setValue(0);/*from  www  . j  a  v a 2  s . com*/
        progressBar.setStringPainted(true);
        progressBar.setEnabled(false);
    }
    return progressBar;
}

From source file:org.zaproxy.zap.extension.portscan.PortScanPanel.java

private JProgressBar getProgressBar() {
    if (progressBar == null) {
        progressBar = new JProgressBar(0, this.extension.getMaxPort());
        progressBar.setValue(0);//from  www .  ja va2s. com
        progressBar.setStringPainted(true);
        progressBar.setEnabled(false);
    }
    return progressBar;
}

From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java

private void createReadingProgressBar() {
    progressBar = new JProgressBar(0, 100);
    progressBar.setStringPainted(true);/*www  . j av  a  2 s  .  c o  m*/
    progressBar.setString("Processed ? of ? [?%]");
    final Timer t = new Timer(500, e -> {
        LOGGER.trace("Updating reading progress");
        final LoadingDetails loadingDetails = logLoader.getLoadingDetails(dataTableModel);
        final List<LogLoadingSession> logLoadingSessions = loadingDetails.getLogLoadingSessions();
        final List<LoadStatistic> statistics = logLoadingSessions.stream().map(logLoader::getLoadStatistic)
                .collect(Collectors.toList());
        final Long position = statistics.stream().collect(Collectors.summingLong(LoadStatistic::getPosition));
        final Long total = statistics.stream().collect(Collectors.summingLong(LoadStatistic::getTotal));
        final float percent = (100f) * ((float) position / total);
        progressBar.setValue((int) percent);
        final String msg = String.format("Processed %s of %s [%.2f%%]",
                FileSize.convertToStringRepresentation(position), FileSize.convertToStringRepresentation(total),
                percent);
        LOGGER.trace("Updating progress bar with message {}", msg);
        progressBar.setString(msg);

        final String tooltip = "<HTML>" + statistics.stream()
                .map(s -> String.format("Processed %s of %s [%.2f%%]  - %s",
                        FileSize.convertToStringRepresentation(s.getPosition()),
                        FileSize.convertToStringRepresentation(s.getTotal()), s.getPercent(),
                        s.getSource().stringForm()))
                .collect(Collectors.joining("<BR/>")) + "</HTML>";
        progressBar.setToolTipText(tooltip);
    });
    t.setRepeats(true);
    t.setInitialDelay(1000);
    t.start();
    timer = Optional.of(t);
}

From source file:plugins.ImageRectificationPanel.java

public final void createGui() {
    this.removeAll();

    if (imageGCPsXCoords == null) {
        return;//from ww  w.  ja v  a 2 s.c  om
    }
    int i;
    int newN = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            newN++;
        }
    }
    double[] X1 = new double[newN];
    double[] Y1 = new double[newN];
    double[] X2 = new double[newN];
    double[] Y2 = new double[newN];

    int j = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            X1[j] = imageGCPsXCoords[i];
            Y1[j] = imageGCPsYCoords[i];
            X2[j] = mapGCPsXCoords[i];
            Y2[j] = mapGCPsYCoords[i];
            j++;
        }
    }

    calculateEquations(X1, Y1, X2, Y2);

    // gui stuff
    this.setLayout(new BorderLayout());

    DecimalFormat df = new DecimalFormat("###,###,##0.000");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
    JButton btnOK = createButton(bundle.getString("OK"), bundle.getString("OK"), "ok");
    JButton btnExit = createButton(bundle.getString("Close"), bundle.getString("Close"), "close");
    //JButton btnRefresh = createButton("Cancel", "Cancel");

    buttonPane.add(Box.createHorizontalStrut(10));
    buttonPane.add(btnOK);
    buttonPane.add(Box.createHorizontalStrut(5));
    //buttonPane.add(btnRefresh);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(btnExit);
    buttonPane.add(Box.createHorizontalGlue());

    progressBar = new JProgressBar(0, 100);
    buttonPane.add(progressBar);
    buttonPane.add(Box.createHorizontalStrut(5));
    cancel = new JLabel(bundle.getString("Cancel"));
    cancel.setForeground(Color.BLUE.darker());
    cancel.addMouseListener(this);
    buttonPane.add(cancel);
    buttonPane.add(Box.createHorizontalStrut(10));

    this.add(buttonPane, BorderLayout.SOUTH);

    Box mainBox = Box.createVerticalBox();
    mainBox.add(Box.createVerticalStrut(10));

    Box box1 = Box.createHorizontalBox();
    box1.add(Box.createHorizontalStrut(10));
    box1.add(new JLabel(bundle.getString("PolynomialOrder") + ": "));
    SpinnerModel model = new SpinnerNumberModel(polyOrder, //initial value
            1, //min
            5, //max
            1); //step

    polyOrderSpinner = new JSpinner(model);
    polyOrderSpinner.setPreferredSize(new Dimension(15, polyOrderSpinner.getPreferredSize().height));
    polyOrderSpinner.addChangeListener(this);

    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) polyOrderSpinner.getEditor();
    editor.getTextField().setEnabled(true);
    editor.getTextField().setEditable(false);

    box1.add(polyOrderSpinner);
    box1.add(Box.createHorizontalGlue());
    JLabel label = new JLabel("RMSE: " + df.format(overallRMSE));
    box1.add(label);
    box1.add(Box.createHorizontalStrut(10));
    mainBox.add(box1);

    mainBox.add(Box.createVerticalStrut(10));

    // Create columns names
    int numPoints = imageGCPsXCoords.length;
    Object dataValues[][] = new Object[numPoints][7];
    j = 0;
    for (i = 0; i < numPoints; i++) {
        dataValues[i][0] = i + 1;
        dataValues[i][1] = df.format(imageGCPsXCoords[i]);
        dataValues[i][2] = df.format(imageGCPsYCoords[i]);
        dataValues[i][3] = df.format(mapGCPsXCoords[i]);
        dataValues[i][4] = df.format(mapGCPsYCoords[i]);
        if (useGCP[i]) {
            dataValues[i][5] = df.format(residualsXY[j]);
            j++;
        } else {
            dataValues[i][5] = null;
        }
        dataValues[i][6] = useGCP[i];
    }

    String columnNames[] = { "GCP", bundle.getString("Image") + " X", bundle.getString("Image") + " Y",
            bundle.getString("Map") + " X", bundle.getString("Map") + " Y", messages.getString("Error"),
            "Use" };

    DefaultTableModel tableModel = new DefaultTableModel(dataValues, columnNames);

    dataTable = new JTable(tableModel) {
        private static final long serialVersionUID = 1L;

        @Override
        public Class getColumnClass(int column) {
            switch (column) {
            case 0:
                return Integer.class;
            case 1:
                return String.class; //Double.class;
            case 2:
                return String.class; //Double.class;
            case 3:
                return String.class; //Double.class;
            case 4:
                return String.class; //Double.class;
            case 5:
                return String.class; //Double.class;
            case 6:
                return Boolean.class;
            default:
                return String.class; //Double.class;
            }
        }

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col) {
            Component comp = super.prepareRenderer(renderer, index_row, index_col);
            //even index, selected or not selected

            if (index_row % 2 == 0) {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            } else {
                comp.setBackground(new Color(225, 245, 255)); //new Color(210, 230, 255));
                comp.setForeground(Color.BLACK);
            }
            if (isCellSelected(index_row, index_col)) {
                comp.setForeground(Color.RED);
            }
            return comp;
        }
    };

    tableModel.addTableModelListener(this);

    TableCellRenderer rend = dataTable.getTableHeader().getDefaultRenderer();
    TableColumnModel tcm = dataTable.getColumnModel();
    //for (int j = 0; j < tcm.getColumnCount(); j += 1) {
    TableColumn tc = tcm.getColumn(0);
    TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    Component c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 0);
    tc.setPreferredWidth(35);

    tc = tcm.getColumn(6);
    rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 6);
    tc.setPreferredWidth(35);

    JScrollPane scroll = new JScrollPane(dataTable);
    mainBox.add(scroll);

    this.add(mainBox, BorderLayout.CENTER);

    this.validate();
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initComponents() throws Exception {
    comboOptions = new UIComboOptions();
    if (!dao.isGuestMode()) {
        List<String> datasetNames = dao.getDatasetNames();
        // create inputs fields
        datasetCombo = new JComboBox(datasetNames.toArray(new String[datasetNames.size()]));
        datasetCombo/*from   w w  w  . j  ava2 s.  com*/
                .setPrototypeDisplayValue("White-faced capuchin, ARTS Crofoot Barro Colorado Island, Panama");
        datasetCombo.setRenderer(new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index,
                    boolean isSelected, boolean cellHasFocus) {
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (index == -1) {
                    datasetCombo.setToolTipText(value.toString());
                    return this;
                }

                setToolTipText(value.toString());
                Rectangle textRect = new Rectangle(datasetCombo.getSize().width, getPreferredSize().height);
                String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()),
                        value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(),
                        getHorizontalTextPosition(), getVerticalTextPosition(), textRect, new Rectangle(),
                        textRect, getIconTextGap());
                setText(shortText);
                return this;
            }
        });
        AutoCompleteDecorator.decorate(datasetCombo);
        datasetLabel = new JLabel("Dataset: ");
    }
    /*Fei*/
    this.dMaxThresLabel = new JLabel("Dist thres(meters): ");
    this.lMaxThresLabel = new JLabel("Time thres(seconds): ");
    this.minIntervalLengthLabel = new JLabel("Min Interval Length(seconds): ");
    this.dMaxLabelTextedField = new JTextField(5);
    this.lMaxLabelTextedField = new JTextField(5);
    this.minIntervalLengthField = new JTextField(5);
    /**/
    functionCombo = new JComboBox(comboOptions.getFunctionOptions());
    displayMethodCombo = new JComboBox(comboOptions.getDvOption());
    gapCombo = new JComboBox(comboOptions.getGapOption());
    thresGapCombo = new JComboBox(comboOptions.getThresGapOption());
    numRoundCombo = new JComboBox(comboOptions.getNumRoundOption());
    functionLabel = new JLabel("Mining function: ");
    dvLabel = new JLabel("Display method: ");
    gapLabel = new JLabel("Gap(min): ");
    thresGapLabel = new JLabel("ThresGap(hr): ");
    numRoundLabel = new JLabel("# Rounds: ");
    instructionLabel = new JLabel("Please select a dataset and some parameters");
    distThresLabel = new JLabel("Dist thres(meters): ");
    this.interpLabel = new JLabel("Interpolate: ");
    distThresTextedField = new JTextField(5);
    downloadDatasetProgressBar = new JProgressBar(0, 100);
    downloadDatasetProgressBar.setValue(0);
    downloadDatasetProgressBar.setStringPainted(true);
    dataInterpolationHelpButton = new JButton("?");
    miningFucntionHelpButton = new JButton("?");
    miningFucntionParamsHelpButton = new JButton("?");
    this.miningFunctionParamsHelpButtonFollowing = new JButton("?");
    selectIndividualsButton = new JButton("Select individuals");
    selectIndividualsButton.addActionListener(this);
    saveKmlButton = new JButton("Get KML file");
    saveKmlButton.addActionListener(this);
    saveDensityMapButton = new JButton("Get density map");
    saveDensityMapButton.addActionListener(this);

}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java

/**
 * Inits the components./*from ww  w  .j  a  va 2s  .co  m*/
 * @param view the ModularDockingApplicationView to register with the ApplicationService
 */
public synchronized void initComponents(ModularDockingApplicationView view) {

    // register self with applicationService and errorLogService within
    logger.debug("applicationService = " + applicationService);
    while (applicationService == null) {
        // idle in this thread
        try {
            this.wait(waitTime);
        } catch (InterruptedException e) {
            logger.warn("e.getMessage() = " + e.getMessage());
        }
    }
    // register this modular view with applicationService
    applicationService.registerFrameView(view);

    mainPanel = new JPanel(new BorderLayout());

    statusMessageLabel = new JLabel("Application started");
    statusMessageLabel.setHorizontalAlignment(SwingConstants.LEFT);
    statusMessageLabel.setVerticalAlignment(SwingConstants.CENTER);
    busyLabel = new JXBusyLabel(new Dimension(18, 19));
    BusyPainter painter = new BusyPainter(new RoundRectangle2D.Float(0, 0, 8.0f, 1.9f, 10.0f, 10.0f),
            new Ellipse2D.Float(2.5f, 2.5f, 14.0f, 14.0f));
    painter.setTrailLength(4);
    painter.setPoints(16);
    painter.setFrame(4);
    busyLabel.setPreferredSize(new Dimension(18, 19));
    busyLabel.setIcon(new EmptyIcon(18, 19));
    busyLabel.setBusyPainter(painter);
    busyLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

    // create progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setVisible(false);
    progressBar.setName("progressBar"); // NOI18N
    mainPanel.setName("mainPanel"); // NOI18N
    statusMessageLabel.setName("statusMessageLabel"); // NOI18N
    busyLabel.setName("statusAnimationLabel"); // NOI18N

    // check workspace file exists
    createWorkspacePersistenceFile();

    // create menuBar
    createMenuBar();
    // create toolbar
    createToolBar();
    // create status bar
    createStatusBar();

    // set menubar
    setMenuBar(menuBar);
    // set toolbar
    setToolBar(toolBar);
    // set status bar
    setStatusBar(jxStatusBar);

    // create tool window
    initToolWindows();

    // set tool window to main content
    setComponent(toolWindowManager);

    // create task monitor and exit listeners
    createTasMonitorAndExitListeners();
}