Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

In this page you can find the example usage for java.awt Cursor getPredefinedCursor.

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:org.languagetool.gui.ResultAreaHelper.java

@Override
public void languageToolEventOccurred(LanguageToolEvent event) {
    if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
        Language lang = ltSupport.getLanguage();
        String langName;/*ww w  .j  a  v  a2s.co  m*/
        if (lang.isExternal()) {
            langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX;
        } else {
            langName = lang.getTranslatedName(messages);
        }
        String msg = org.languagetool.tools.Tools.i18n(messages, "startChecking", langName) + "...";
        setHeader(msg);
        setMain(EMPTY_PARA);
        if (event.getCaller() == this) {
            statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
    } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
        setRunTime(event.getElapsedTime());
        String inputText = event.getSource().getTextComponent().getText();
        displayResult(inputText, event.getSource().getMatches());
        if (event.getCaller() == this) {
            statusPane.setCursor(Cursor.getDefaultCursor());
        }
    } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED
            || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
        String inputText = event.getSource().getTextComponent().getText();
        displayResult(inputText, event.getSource().getMatches());
    }
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public JTextPane createJTextPane(String text) {
    JTextPane jtp = new JTextPane();
    jtp.setText(text);/*from w w  w.  j  av  a 2 s .co m*/
    SimpleAttributeSet underline = new SimpleAttributeSet();
    StyleConstants.setUnderline(underline, true);
    jtp.getStyledDocument().setCharacterAttributes(0, text.length(), underline, true);
    jtp.setEditable(false);
    jtp.setOpaque(false);
    jtp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    jtp.setBorder(BorderFactory.createEmptyBorder());
    jtp.setForeground(Color.blue);
    jtp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return jtp;
}

From source file:io.github.jeddict.jsonb.modeler.widget.JSONNodeWidget.java

protected void addOpenSourceCodeAction() {
    this.getImageWidget().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    this.getImageWidget().getActions().addAction(new OpenSourceCodeAction(
            () -> getFileObject(this.getBaseElementSpec().getAttribute().getJavaClass(),
                    this.getModelerScene().getModelerFile().getParentFile()),
            this.getBaseElementSpec().getAttribute(), this.getModelerScene().getModelerFile().getParentFile()));
}

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

/**
 * Creates a time slider with the maximum available range.
 *///from   w  w w  . jav  a  2 s  . c  om
public TimeSlider() {
    super();

    minimum = 0;
    start = 0;
    value = 0;
    end = Double.MAX_VALUE;
    maximum = Double.MAX_VALUE;

    valueChangeable = true;
    rangeChangeable = true;

    isAdjusting = false;

    markers = new ArrayList<EventMarker>();

    timeRanges = new ArrayList<TimeRange>();

    actualTimeRanges = new ArrayList<TimeRange>();
    calculateActualTimeRanges();

    adjustmentListeners = new ArrayList<TimeAdjustmentListener>();

    setBorder(null);
    setLayout(null);

    setToolTipText("");

    addMouseListener(this);

    valueButton = new JButton(DataViewer.getIcon("icons/time.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8729851598067678522L;

        public JToolTip createToolTip() {
            return TimeSlider.this.createToolTip();
        }

        public String getToolTipText(MouseEvent me) {
            return TimeSlider.this.getToolTipText(me);
        }
    };
    valueButton.setToolTipText("");
    valueButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    valueButton.setOpaque(false);
    valueButton.setBorder(null);
    valueButton.addMouseMotionListener(this);
    valueButton.addMouseListener(this);
    add(valueButton);

    startButton = new JButton(DataViewer.getIcon("icons/left_bound.gif"));
    startButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    startButton.setOpaque(false);
    startButton.setBorder(null);
    startButton.addMouseListener(this);
    startButton.addMouseMotionListener(this);
    add(startButton);

    endButton = new JButton(DataViewer.getIcon("icons/right_bound.gif"));
    endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    endButton.setOpaque(false);
    endButton.setBorder(null);
    endButton.addMouseListener(this);
    endButton.addMouseMotionListener(this);
    add(endButton);

    defaultMarkerImage = DataViewer.getImage("icons/marker.gif");
    annotationMarkerImage = DataViewer.getImage("icons/marker-annotation.gif");
    startMarkerImage = DataViewer.getImage("icons/marker-start.gif");
    stopMarkerImage = DataViewer.getImage("icons/marker-stop.gif");
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Supplies the JPanel which is displayed in the main Jogra window.
 *///www.jav a2s .  c  o m
public JPanel getMainWindowPlugin() {

    final JPanel ret = new JPanel();
    final JButton loadButton = new JButton("Load Term Rationaliser");
    final JLabel chooseType = new JLabel("Select term: ");
    final JComboBox termTypeBox = new JComboBox(instances.keySet().toArray());
    final JCheckBox showEVCFilter = new JCheckBox("Highlight terms with evidence codes", true);

    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {

            new SwingWorker<JFrame, Void>() {
                @Override
                protected JFrame doInBackground() throws Exception {
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    setTermType(instances.get((String) termTypeBox.getSelectedItem()));
                    setShowEVC(showEVCFilter.isSelected());
                    return makeWindow();
                }

                @Override
                public void done() {
                    try {
                        final GeneDBMessage e = new OpenWindowEvent(TermRationaliser.this, get());
                        EventBus.publish(e);
                    } catch (final InterruptedException exp) {
                        exp.printStackTrace();
                    } catch (final ExecutionException exp) {
                        exp.printStackTrace();
                    }
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }.execute();
        }
    });
    Box verticalBox = Box.createVerticalBox();
    Box horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(chooseType);
    horizontalBox.add(termTypeBox);
    verticalBox.add(horizontalBox);
    verticalBox.add(loadButton);
    verticalBox.add(showEVCFilter);
    ret.add(verticalBox);
    return ret;
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image toggle button./*w w w.j av  a 2  s  .co  m*/
 * 
 * @return the newly created image toggle button
 */
public static JToggleButton newImageToggleButton() {
    JToggleButton button = new JToggleButton();

    button.setBorder(new EmptyBorder(2, 2, 2, 8));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setContentAreaFilled(false);
    button.setFocusable(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return button;
}

From source file:op.care.med.structure.DlgProduct.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from w ww .j a v a  2  s  . c  o  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents
private void initComponents() {
    lblProductName = new JLabel();
    txtName = new JTextField();
    cmbAcme = new JComboBox<>();
    lblAcme = new JLabel();
    btnAdd = new JButton();
    lblSideEffects = new JLabel();
    scrollPane1 = new JScrollPane();
    txtSideEffects = new JTextArea();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnOK = new JButton();

    //======== this ========
    setModal(true);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("2*(default, $lcgap), default:grow, 2*($lcgap, default)",
            "default, 2*($lgap, fill:default), $lgap, fill:default:grow, $lgap, fill:default, $lgap, default"));

    //---- lblProductName ----
    lblProductName.setText("Produktname");
    lblProductName.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblProductName, CC.xy(3, 3));

    //---- txtName ----
    txtName.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(txtName, CC.xywh(5, 3, 3, 1));

    //---- cmbAcme ----
    cmbAcme.setModel(
            new DefaultComboBoxModel<>(new String[] { "Eintrag 1", "Eintrag 2", "Eintrag 3", "Eintrag 4" }));
    cmbAcme.setFont(new Font("Arial", Font.PLAIN, 14));
    cmbAcme.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            cmbAcmeItemStateChanged(e);
        }
    });
    contentPane.add(cmbAcme, CC.xy(5, 5));

    //---- lblAcme ----
    lblAcme.setText("Hersteller");
    lblAcme.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblAcme, CC.xy(3, 5));

    //---- btnAdd ----
    btnAdd.setText(null);
    btnAdd.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
    btnAdd.setContentAreaFilled(false);
    btnAdd.setBorder(null);
    btnAdd.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
    btnAdd.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnAddActionPerformed(e);
        }
    });
    contentPane.add(btnAdd, CC.xy(7, 5, CC.LEFT, CC.DEFAULT));

    //---- lblSideEffects ----
    lblSideEffects.setText("Hersteller");
    lblSideEffects.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblSideEffects, CC.xy(3, 7, CC.DEFAULT, CC.TOP));

    //======== scrollPane1 ========
    {

        //---- txtSideEffects ----
        txtSideEffects.setFont(new Font("Arial", Font.PLAIN, 14));
        scrollPane1.setViewportView(txtSideEffects);
    }
    contentPane.add(scrollPane1, CC.xywh(5, 7, 3, 1));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/16x16/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnCancelActionPerformed(e);
            }
        });
        panel1.add(btnCancel);

        //---- btnOK ----
        btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/16x16/apply.png")));
        btnOK.setText(null);
        btnOK.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnOKActionPerformed(e);
            }
        });
        panel1.add(btnOK);
    }
    contentPane.add(panel1, CC.xywh(5, 9, 3, 1, CC.RIGHT, CC.DEFAULT));
    setSize(585, 285);
    setLocationRelativeTo(null);
}

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

private void initComponents(List<String> channels, List<String> fileFormats) {
    channelModel = new DefaultListModel();

    for (int i = 0; i < channels.size(); i++) {
        String channelName = (String) channels.get(i);
        Channel channel = RBNBController.getInstance().getChannel(channelName);

        String mime = channel.getMetadata("mime");

        if (mime.equals("application/octet-stream")) {
            channelModel.addElement(new ExportChannel(channelName));
        }//w w w .  j a  v  a  2 s.  c  o  m
    }

    JPanel container = new JPanel();
    setContentPane(container);

    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 data 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(ExportDialog.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(ExportDialog.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 = RBNBController.getInstance().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("Data 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);

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

            checkSelectedChannels();

            updateTimeBounds();
        }
    });
    JScrollPane scrollPane = new JScrollPane(numericChannelList);
    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("Data file: "), c);

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

    dataFileTextField
            .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat");
    dataFileButton = new JButton("Browse");
    dataFileButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            File selectedFile = new File(dataFileTextField.getText());
            selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile);
            if (selectedFile != null) {
                dataFileTextField.setText(selectedFile.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(dataFileButton, c);

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

    fileFormatComboBox = new JComboBox(fileFormats.toArray());
    fileFormatComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            fileFormatUpdated();
        }
    });
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(fileFormatComboBox, c);

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

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

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    };
    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 = -5868609501314154642L;

        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());
    }

    dataFileTextField.requestFocusInWindow();

    setLocationByPlatform(true);
}

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

private void initComponents() {

    JPanel container = new JPanel();
    setContentPane(container);//from  w ww  .j  av  a  2  s  .  com

    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:com.mirth.connect.client.ui.MessageImportDialog.java

private void importMessages() {
    if (StringUtils.isBlank(fileTextField.getText())) {
        fileTextField.setBackground(UIConstants.INVALID_COLOR);
        parent.alertError(parent, "Please enter a file/folder to import.");
        setVisible(true);/*from  w ww  .  j a va 2s .  c o m*/
        return;
    } else {
        fileTextField.setBackground(null);
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    MessageImportResult result;

    try {
        if (importLocalRadio.isSelected()) {
            MessageWriter messageWriter = new MessageWriter() {
                @Override
                public boolean write(Message message) throws MessageWriterException {
                    try {
                        parent.mirthClient.importMessage(channelId, message);
                    } catch (ClientException e) {
                        throw new MessageWriterException(e);
                    }

                    return true;
                }

                @Override
                public void finishWrite() {
                }

                @Override
                public void close() throws MessageWriterException {
                }
            };

            try {
                result = new MessageImporter().importMessages(fileTextField.getText(),
                        subfoldersCheckbox.isSelected(), messageWriter,
                        SystemUtils.getUserHome().getAbsolutePath());
            } catch (MessageImportInvalidPathException e) {
                setCursor(Cursor.getDefaultCursor());
                parent.alertError(parent, e.getMessage());
                setVisible(true);
                return;
            }
        } else {
            result = parent.mirthClient.importMessagesServer(channelId, fileTextField.getText(),
                    subfoldersCheckbox.isSelected());
        }

        setVisible(false);
        setCursor(Cursor.getDefaultCursor());

        if (result.getSuccessCount() == 0 && result.getTotalCount() == 0) {
            parent.alertInformation(parent, "No messages were found to import");
        } else {
            if (result.getSuccessCount() > 0 && messageBrowser != null) {
                messageBrowser.updateFilterButtonFont(Font.BOLD);
            }

            parent.alertInformation(parent, result.getSuccessCount() + " out of " + result.getTotalCount()
                    + " message(s) have been successfully imported from " + fileTextField.getText() + ".");
        }
    } catch (Exception e) {
        setCursor(Cursor.getDefaultCursor());
        Throwable cause = (e.getCause() == null) ? e : e.getCause();
        parent.alertThrowable(parent, cause);
    }
}