Example usage for java.awt Cursor WAIT_CURSOR

List of usage examples for java.awt Cursor WAIT_CURSOR

Introduction

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

Prototype

int WAIT_CURSOR

To view the source code for java.awt Cursor WAIT_CURSOR.

Click Source Link

Document

The wait cursor type.

Usage

From source file:brainflow.app.toplevel.BrainFlow.java

public void loadAndDisplay(final IImageSource dataSource) {
    //this whole set of methods is a horror
    //todo need a set of related methods that allow
    // 1. loading image in background
    // 2. registering image
    // 3. creating model if necessary
    // 4. creating layer if necessary
    // 5. creating view if necessary

    log.info("loading and displaying : " + dataSource);

    final Cursor cursor = brainFrame.getCursor();
    brainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    final IImageSource checkedDataSource = specialHandling(dataSource);
    register(checkedDataSource);// w w w .  ja  v a 2  s  . c o  m

    ImageProgressMonitor monitor = new ImageProgressMonitor(checkedDataSource, brainFrame.getContentPane());
    monitor.loadImage(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ImageViewModel displayModel = ProjectManager.get().createViewModel(checkedDataSource, true);
            ImageView iview = ImageViewFactory.createAxialView(displayModel);
            DisplayManager.get().display(iview);
            brainFrame.setCursor(cursor);
        }
    });

}

From source file:us.paulevans.basicxslt.BasicXSLTFrame.java

/**
 * Method to handle button clicks.//from  w w  w.j a  v a  2s  .co m
 * @param evt
 */
public void actionPerformed(ActionEvent evt) {

    String actionCommand, action, allConfigurations[];
    Object eventSource;
    XSLRow xslRow;

    eventSource = evt.getSource();
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    try {
        if (eventSource == transformBtn) {
            if (areAnyStylesheets()) {
                doTransform();
            } else {
                Utils.showDialog(this,
                        stringFactory
                                .getString(LabelStringFactory.MAIN_FRAME_SPECIFICY_AT_LEAST_ONE_STYLESHEET),
                        stringFactory.getString(LabelStringFactory.MAIN_FRAME_TRANSFORM_MESSAGE),
                        JOptionPane.ERROR_MESSAGE);
            }
        } else if (eventSource == about) {
            about();
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == exit) {
            destroy();
        } else if (eventSource == transformTimings) {
            new TimingsFrame(this, Utils.toArray(xslRows));
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == validateAutosaveBtn) {
            doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE), autosavePathTf,
                    false);
        } else if (eventSource == exitBtn) {
            destroy();
        } else if (eventSource == resetForm) {
            resetForm();
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == browseAutosavePathBtn) {
            populateTFFromFileDialog(autosavePathTf);
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == browseXmlBtn) {
            populateTFFromFileDialog(sourceXmlTf);
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == autosaveCb) {
            autosavePathTf.setEnabled(autosaveCb.isSelected());
            browseAutosavePathBtn.setEnabled(autosaveCb.isSelected());
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == suppressOutputWindowCb) {
            outputAsTextIfXmlLabel.setEnabled(!suppressOutputWindowCb.isSelected());
            outputAsTextIfXml.setEnabled(!suppressOutputWindowCb.isSelected());
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == removeCheckedBtn) {
            transformTimings.setEnabled(false);
            XSLRow.removeChecked(xslRows);
            if (xslRows.size() == 0) {
                addXSLRow();
                refreshXSLPanel();
            }
            enableRemoveCheckedBtn();
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == addXslBtn) {
            transformTimings.setEnabled(false);
            addXSLRow();
            refreshXSLPanel();
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == saveConfiguration) {
            persistUserPrefs();
            userPrefs.persistUserPrefs();
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == saveAsConfiguration) {
            new SaveAsConfigurationFrame(this, userPrefs.getConfiguration());
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        } else if (eventSource == loadConfiguration) {
            allConfigurations = userPrefs.getAllConfigurations();
            if (allConfigurations.length > 0) {
                new LoadConfigurationFrame(this, userPrefs.getConfiguration(), allConfigurations);
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            } else {
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                Utils.showDialog(this,
                        MessageFormat.format(
                                stringFactory.getString(LabelStringFactory.MAIN_FRAME_ONLY_CONFIGURATION),
                                userPrefs.getConfiguration(), saveAsConfiguration.getText()),
                        stringFactory.getString(LabelStringFactory.MAIN_FRAME_MESSAGE),
                        JOptionPane.INFORMATION_MESSAGE);
            }
        } else if (eventSource == xmlAction) {
            if (xmlAction.getItemCount() > 0) {
                action = (String) xmlAction.getSelectedItem();
                xmlAction.setSelectedIndex(0);
                if (action.equals(XML_ACTIONS[XML_VALIDATE_ACTION_INDEX])) {
                    components.clear();
                    components.add(sourceXmlTf);
                    components.add(xmlAction);
                    components.add(browseXmlBtn);
                    doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE), sourceXmlTf,
                            false);
                } else if (action.equals(XML_ACTIONS[XML_VIEW_EDIT_OUTPUT_PROPS_INDEX])) {
                    new TransformOutputPropertiesFrame(this, xmlIdentityTransformOutputProps,
                            sourceXmlTf.getText());
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                } else if (action.equals(XML_ACTIONS[XML_CLEAR_OUTPUT_PROPS_INDEX])) {
                    xmlIdentityTransformOutputProps.clear();
                    setAreOutputPropertiesSet(false);
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                } else if (action.equals(XML_ACTIONS[XML_DO_IDENTITY_TRANSFORM_ACTION_INDEX])) {

                    if (validateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XML_FILE),
                            sourceXmlTf, true)) {
                        components.clear();
                        components.add(sourceXmlTf);
                        components.add(browseXmlBtn);
                        components.add(xmlAction);
                        doIdentityTransform(
                                stringFactory
                                        .getString(LabelStringFactory.MAIN_FRAME_SELECT_FILE_FOR_IT_RESULT),
                                sourceXmlTf.getText(), sourceXmlTf.getText());
                    } else {
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    }
                } else {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                }
            }
        } else {
            actionCommand = evt.getActionCommand();
            if (AppConstants.INSERT.equals(actionCommand)) {
                xslRow = XSLRow.getRowByInsertBtn(xslRows, (JButton) eventSource);
                insertXSLRow(xslRow.getIndex());
                refreshXSLPanel();
            } else if (AppConstants.REMOVE_CB.equals(actionCommand)) {
                enableRemoveCheckedBtn();
            } else if (stringFactory.getString(LabelStringFactory.MAIN_FRAME_BROWSE_BTN)
                    .equals(actionCommand)) {
                xslRow = XSLRow.getRowByBrowseBtn(xslRows, (JButton) eventSource);
                populateTFFromFileDialog(xslRow.getTextField());
            } else if (AppConstants.TAKE_ACTION.equals(actionCommand)) {
                xslRow = XSLRow.getRowByAction(xslRows, (JComboBox) eventSource);
                if (xslRow.getAction().getItemCount() > 0) {
                    action = (String) xslRow.getAction().getSelectedItem();
                    xslRow.setSelectedActionIndex(0);
                    if (action.equals(XSLRow.ACTIONS[XSLRow.VALIDATE_INDEX])) {
                        components.clear();
                        components.add(xslRow.getTextField());
                        components.add(xslRow.getAction());
                        components.add(xslRow.getRemoveCb());
                        components.add(xslRow.getInsertBtn());
                        components.add(xslRow.getBrowseBtn());
                        doValidateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XSL_PREFIX)
                                + (xslRow.getIndex() + 1), xslRow.getTextField(), false);
                    } else if (action.startsWith(XSLRow.ON_OFF_ITEM_PREFIX)) {
                        xslRow.toggleOnOffBtn();
                    } else if (action.equals(XSLRow.ACTIONS[XSLRow.VIEW_EDIT_OUTPUT_PROPS_INDEX])) {
                        new TransformOutputPropertiesFrame(this, xslRow);
                    } else if (action.equals(XSLRow.ACTIONS[XSLRow.CLEAR_OUTPUT_PROPS_INDEX])) {
                        xslRow.setAreOutputPropertiesSet(false);
                        xslRow.clearOutputProperties();
                    } else if (action.equals(XSLRow.ACTIONS[XSLRow.CLEAR_ALL_PARAMETERS_INDEX])) {
                        xslRow.clearAllParameters();
                    } else if (action.equals(XSLRow.ACTIONS[XSLRow.VIEW_EDIT_PARAMETERS_INDEX])) {
                        new TransformParametersFrame(this, xslRow);
                    } else if (action.equals(XSLRow.ACTIONS[XSLRow.PERFORM_IDENTITY_TRANSFORM_INDEX])) {
                        if (validateXml(stringFactory.getString(LabelStringFactory.MAIN_FRAME_XSL_PREFIX)
                                + (xslRow.getIndex() + 1), xslRow.getTextField(), true)) {
                            components.clear();
                            components.add(xslRow.getBrowseBtn());
                            components.add(xslRow.getRemoveCb());
                            components.add(xslRow.getInsertBtn());
                            components.add(xslRow.getTextField());
                            doIdentityTransform(
                                    stringFactory.getString(LabelStringFactory.MAIN_FRAME_PICK_FILE_FOR_IT),
                                    xslRow.getTextField().getText(), xslRow.getTextField().getText());
                        } else {
                            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                        }
                    }
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } catch (Throwable aAny) {
        // log and show dialog...
        logger.error(ExceptionUtils.getFullStackTrace(aAny));
        Utils.showErrorDialog(this, aAny);
    }
}

From source file:com.openbravo.pos.util.JRViewer411.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed
 // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewer411.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled()) {
                    log.error("Print error.", ex);
                }//from  w w w  .j av a2s.  c  o  m
                JOptionPane.showMessageDialog(JRViewer411.this, getBundleString("error.printing"));
            } finally {
                JRViewer411.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }
        }
    });

    thread.start();

}

From source file:brainflow.app.toplevel.BrainFlow.java

public void load(final IImageSource dataSource) {
    final Cursor cursor = brainFrame.getCursor();
    brainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    final IImageSource checkedDataSource = specialHandling(dataSource);
    ImageProgressMonitor monitor = new ImageProgressMonitor(checkedDataSource, brainFrame.getContentPane());

    monitor.loadImage(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            register(checkedDataSource);
            brainFrame.setCursor(cursor);
        }/*from  w  ww  .  j  a  v a  2  s .co m*/
    });

}

From source file:de.bfs.radon.omsimulation.gui.OMPanelTesting.java

/**
 * Initialises the interface of the results panel.
 *//*from  w w  w  .  jav a 2  s. co m*/
protected void initialize() {

    setLayout(null);
    isSimulated = false;

    lblExportChartTo = new JLabel("Export chart to ...");
    lblExportChartTo.setBounds(436, 479, 144, 14);
    lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblExportChartTo.setVisible(false);
    add(lblExportChartTo);

    btnCsv = new JButton("CSV");
    btnCsv.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String csv;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("csv")) {
                    csv = "";
                } else {
                    csv = ".csv";
                }
                String csvPath = file.getAbsolutePath() + csv;
                double[] selectedValues;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                final int day = 24;
                File csvFile = new File(csvPath);
                try {
                    OMCampaign campaign;
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    FileWriter logWriter = new FileWriter(csvFile);
                    BufferedWriter csvOutput = new BufferedWriter(logWriter);
                    csvOutput.write("\"ID\";\"Room\";\"Radon\"");
                    csvOutput.newLine();
                    selectedValues = campaign.getValueChain();
                    int x = 0;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[0].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[1].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[2].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[3].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[4].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[5].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[6].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                    csvOutput.close();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnCsv.setBounds(590, 475, 70, 23);
    btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnCsv.setVisible(false);
    add(btnCsv);

    btnPdf = new JButton("PDF");
    btnPdf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String pdf;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("pdf")) {
                    pdf = "";
                } else {
                    pdf = ".pdf";
                }
                String pdfPath = file.getAbsolutePath() + pdf;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                OMCampaign campaign;
                try {
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    JFreeChart chart = OMCharts.createCampaignChart(campaign, false);
                    String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                            + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                            + ", Start: " + start;
                    int height = (int) PageSize.A4.getWidth();
                    int width = (int) PageSize.A4.getHeight();
                    try {
                        OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title);
                        JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success",
                                JOptionPane.INFORMATION_MESSAGE);
                    } catch (IOException ioe) {
                        JOptionPane.showMessageDialog(null,
                                "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed",
                                JOptionPane.ERROR_MESSAGE);
                        ioe.printStackTrace();
                    }
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null, "Failed to create chart!\n" + ioe.getMessage(),
                            "Failed", JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnPdf.setBounds(670, 475, 70, 23);
    btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnPdf.setVisible(false);
    add(btnPdf);

    lblSelectProject = new JLabel("Select Project");
    lblSelectProject.setBounds(10, 65, 132, 14);
    lblSelectProject.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectProject);

    lblSelectRooms = new JLabel("Select Rooms");
    lblSelectRooms.setBounds(10, 94, 132, 14);
    lblSelectRooms.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectRooms);

    lblStartTime = new JLabel("Start Time");
    lblStartTime.setBounds(10, 123, 132, 14);
    lblStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblStartTime);

    lblWarning = new JLabel("Select 6 rooms and 1 cellar!");
    lblWarning.setForeground(Color.RED);
    lblWarning.setBounds(565, 123, 175, 14);
    lblWarning.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblWarning.setVisible(false);
    add(lblWarning);

    sliderStartTime = new JSlider();
    sliderStartTime.setMaximum(0);
    sliderStartTime.setBounds(152, 119, 285, 24);
    sliderStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(sliderStartTime);

    spnrStartTime = new JSpinner();
    spnrStartTime.setModel(new SpinnerNumberModel(0, 0, 0, 1));
    spnrStartTime.setBounds(447, 120, 108, 22);
    spnrStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(spnrStartTime);

    btnRefresh = new JButton("Load");
    btnRefresh.setBounds(616, 61, 124, 23);
    btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnRefresh);

    btnMaximize = new JButton("Fullscreen");
    btnMaximize.setBounds(10, 475, 124, 23);
    btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnMaximize);

    panelCampaign = new JPanel();
    panelCampaign.setBounds(10, 150, 730, 315);
    panelCampaign.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(panelCampaign);

    progressBar = new JProgressBar();
    progressBar.setBounds(10, 475, 730, 23);
    progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11));
    progressBar.setVisible(false);
    add(progressBar);

    lblOpenOmbfile = new JLabel("Open OMB-File");
    lblOpenOmbfile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblOpenOmbfile.setBounds(10, 36, 132, 14);
    add(lblOpenOmbfile);

    lblHelp = new JLabel("Select an OMB-Object file to manually simulate virtual campaigns.");
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    txtOmbFile = new JTextField();
    txtOmbFile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    txtOmbFile.setColumns(10);
    txtOmbFile.setBounds(152, 33, 454, 20);
    add(txtOmbFile);

    btnBrowse = new JButton("Browse");
    btnBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnBrowse.setBounds(616, 32, 124, 23);
    add(btnBrowse);

    comboBoxRoom1 = new JComboBox<OMRoom>();
    comboBoxRoom1.setBounds(152, 90, 75, 22);
    comboBoxRoom1.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom1);

    comboBoxRoom2 = new JComboBox<OMRoom>();
    comboBoxRoom2.setBounds(237, 90, 75, 22);
    comboBoxRoom2.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom2);

    comboBoxRoom3 = new JComboBox<OMRoom>();
    comboBoxRoom3.setBounds(323, 90, 75, 22);
    comboBoxRoom3.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom3);

    comboBoxRoom4 = new JComboBox<OMRoom>();
    comboBoxRoom4.setBounds(408, 90, 75, 22);
    comboBoxRoom4.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom4);

    comboBoxRoom5 = new JComboBox<OMRoom>();
    comboBoxRoom5.setBounds(494, 90, 75, 22);
    comboBoxRoom5.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom5);

    comboBoxRoom6 = new JComboBox<OMRoom>();
    comboBoxRoom6.setBounds(579, 90, 75, 22);
    comboBoxRoom6.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom6);

    comboBoxRoom7 = new JComboBox<OMRoom>();
    comboBoxRoom7.setBounds(665, 90, 75, 22);
    comboBoxRoom7.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom7);

    comboBoxProjects = new JComboBox<OMBuilding>();
    comboBoxProjects.setBounds(152, 61, 454, 22);
    comboBoxProjects.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxProjects);

    comboBoxRoom1.addActionListener(this);
    comboBoxRoom1.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom2.addActionListener(this);
    comboBoxRoom2.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom3.addActionListener(this);
    comboBoxRoom3.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom4.addActionListener(this);
    comboBoxRoom4.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom5.addActionListener(this);
    comboBoxRoom5.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom6.addActionListener(this);
    comboBoxRoom6.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom7.addActionListener(this);
    comboBoxRoom7.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });

    sliderStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    spnrStartTime.setValue((int) sliderStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    spnrStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    sliderStartTime.setValue((Integer) spnrStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("")
                    && !txtOmbFile.getText().equals(" ")) {
                txtOmbFile.setBackground(Color.WHITE);
                String ombPath = txtOmbFile.getText();
                String omb;
                String[] tmpFileName = ombPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(ombPath + omb);
                setOmbFile(ombPath + omb);
                File ombFile = new File(ombPath + omb);
                if (ombFile.exists()) {
                    txtOmbFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxProjects.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBar.setVisible(true);
                    btnPdf.setVisible(false);
                    btnCsv.setVisible(false);
                    btnMaximize.setVisible(false);
                    lblExportChartTo.setVisible(false);
                    progressBar.setIndeterminate(true);
                    progressBar.setStringPainted(true);
                    refreshTask = new Refresh();
                    refreshTask.execute();
                } else {
                    txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    btnMaximize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                        + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                        + ", Start: " + start;
                OMCampaign campaign;
                if (isResult) {
                    campaign = getResultCampaign();
                } else {
                    campaign = new OMCampaign(start, rooms, 0);
                }
                JPanel campaignChart = createCampaignPanel(campaign, false, true);
                JFrame chartFrame = new JFrame();
                chartFrame.getContentPane().add(campaignChart);
                chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight());
                chartFrame.setTitle(title);
                chartFrame.setResizable(true);
                chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                chartFrame.setVisible(true);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    });
    txtOmbFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            setOmbFile(txtOmbFile.getText());
        }
    });
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String omb;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(file.getAbsolutePath() + omb);
                setOmbFile(file.getAbsolutePath() + omb);
            }
        }
    });
}

From source file:com.vgi.mafscaling.ClosedLoop.java

public void loadData() {
    fileChooser.setMultiSelectionEnabled(false);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//  w  ww. j av  a  2 s  .co  m
    File file = fileChooser.getSelectedFile();
    int i, j;
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    BufferedReader br = null;
    try {
        br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
        String line = br.readLine();
        if (line == null || !line.equals(SaveDataFileHeader)) {
            JOptionPane.showMessageDialog(null, "Invalid saved data file!", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        line = br.readLine();
        String[] elements;
        i = 0;
        int offset = 0;
        boolean isLogData = false;
        while (line != null) {
            elements = line.split(",", -1);
            switch (i) {
            case 0:
                Utils.ensureColumnCount(elements.length - 1, mafTable);
                for (j = 0; j < elements.length - 1; ++j)
                    mafTable.setValueAt(elements[j], i, j);
                break;
            case 1:
                Utils.ensureColumnCount(elements.length - 1, mafTable);
                for (j = 0; j < elements.length - 1; ++j)
                    mafTable.setValueAt(elements[j], i, j);
                break;
            default:
                if (elements.length - 1 == logDataTable.getColumnCount()) {
                    if (!isLogData) {
                        offset = i;
                        isLogData = true;
                    }
                    Utils.ensureRowCount(i - offset + 1, logDataTable);
                    for (j = 0; j < elements.length - 1; ++j)
                        logDataTable.setValueAt(elements[j], i - offset, j);
                }
            }
            i += 1;
            line = br.readLine();
        }
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(e);
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        if (br != null) {
            try {
                br.close();
            } catch (IOException e) {
                logger.error(e);
            }
        }
    }
}

From source file:com.josescalia.tumblr.form.TumblrImageViewer.java

private void setDisplay(List<DownloadableImage> downloadableImageList) {
    frame = (MainFrame) this.getTopLevelAncestor();
    form = this;/*from ww  w . j av a 2  s . c  o m*/
    final List<DownloadableImage> downloadableImages = downloadableImageList;

    form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.startProgressBar("Viewing");

    if (downloadableImages != null && downloadableImages.size() > 0) {
        new SwingWorker<String, String>() {
            @Override
            protected String doInBackground() throws Exception {
                String sReturn = "";
                for (DownloadableImage image : downloadableImages) {
                    String fileName = image.getUrl().substring(image.getUrl().lastIndexOf("/") + 1);
                    String downloadUrl = image.getUrl();
                    if (sReturn.length() > 0) {
                        sReturn += "<br>";
                    }
                    sReturn += "<img src='file:///"
                            + BinaryCacheUtil.getBinaryImagePath(".cache", fileName, downloadUrl) + "'>";
                }
                return sReturn;
            }

            @Override
            protected void done() {
                try {
                    setImageDisplay(get());
                } catch (InterruptedException e) {
                    logger.error(e);
                } catch (ExecutionException e) {
                    logger.error(e);
                }
                form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                frame.stopProgressBar("");
            }
        }.execute();
    }
}

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

/**
 * This method initializes jMenuItemBrowseImages   
 *    //from  w w w  .ja va 2  s .  c  o  m
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getJMenuItemBrowseImages() {
    if (jMenuItemBrowseImages == null) {
        jMenuItemBrowseImages = new JMenuItem();
        jMenuItemBrowseImages.setText("Browse Image Files");
        jMenuItemBrowseImages.setMnemonic(KeyEvent.VK_I);
        try {
            jMenuItemBrowseImages.setIcon(new ImageIcon(this.getClass()
                    .getResource("/edu/harvard/mcz/imagecapture/resources/image_icon_16px.png")));
        } catch (Exception e) {
            log.error("Can't open icon file for jMenuItemBrowseImages.");
            log.error(e);
        }
        jMenuItemBrowseImages.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                // Create a ImageListBrowser jpanel and replace the 
                // the content of the center of jPanelCenter with it.
                //TODO: extend beyond switching between ilb and slb.
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                ilb = new ImageListBrowser();
                if (slb != null) {
                    jPanelCenter.remove(slb);
                }
                if (ulb != null) {
                    jPanelCenter.remove(ulb);
                }
                jPanelCenter.removeAll();
                jPanelCenter.add(ilb, BorderLayout.CENTER);
                jPanelCenter.revalidate();
                jPanelCenter.repaint();
                if (Singleton.getSingletonInstance().getProperties().getProperties()
                        .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) {
                    jMenuItemBrowseSpecimens.setEnabled(false);
                    jMenuItemBrowseImages.setEnabled(false);
                } else {
                    jMenuItemBrowseSpecimens.setEnabled(true);
                    jMenuItemBrowseImages.setEnabled(true);
                }
                setStatusMessage("Found " + ilb.getRowCount() + " images.");
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                System.gc();
            }
        });
    }
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) {
        jMenuItemBrowseImages.setEnabled(false);
    }
    return jMenuItemBrowseImages;
}

From source file:tax.MainForm.java

private void refreshButActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButActionPerformed
    this.setCursor(Cursor.WAIT_CURSOR);
    Util.updateDB();//from   ww w  .j a  v  a2  s.  c o m
    loadTable(curTable);
    this.setCursor(Cursor.DEFAULT_CURSOR);
}

From source file:com.openbravo.pos.util.JRViewer.java

void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
{//GEN-HEADEREND:event_btnPrintActionPerformed

    SwingUtilities.invokeLater(new Runnable() {
        @Override/*from w w w.  j av a  2  s .  c  om*/
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing"));
            } finally {
                JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }
        }
    });

}