Example usage for javax.swing JLabel setEnabled

List of usage examples for javax.swing JLabel setEnabled

Introduction

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

Prototype

@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether or not this component is enabled.

Usage

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("java2s.com");
    label.setEnabled(false);

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("java2s.com");
    label.setEnabled(false);

    f.add(label);//from   w w  w. j  a v  a 2 s. com
    f.pack();
    f.setVisible(true);
}

From source file:AlignLabels.java

public AlignLabels() {
    JLabel label;

    setLayout(new GridLayout(3, 3));

    label = createLabel("NW alignment");
    setNWalignment(label);//w  w  w.  j av a2s  .  c om
    label.setEnabled(false);
    labels[0] = label;
    label = createLabel("N alignment");
    setNalignment(label);
    labels[1] = label;
    label = createLabel("NE alignment");
    setNEalignment(label);
    labels[2] = label;
    label = createLabel("W alignment");
    label.setText("<html><i>html based<br></i><font color=blue>W alignment</font>");
    setWalignment(label);
    labels[3] = label;
    label = createLabel("C alignment");
    setCalignment(label);
    label.setEnabled(false);
    labels[4] = label;
    label = createLabel("E alignment");
    setEalignment(label);
    labels[5] = label;
    label = createLabel("SW alignment");
    setSWalignment(label);
    labels[6] = label;
    label = createLabel("S alignment");
    setSalignment(label);
    labels[7] = label;
    label = createLabel("SE alignment");
    setSEalignment(label);
    label.setEnabled(false);
    labels[8] = label;
}

From source file:edu.ku.brc.specify.config.ResImpExpMetaInfoDlg.java

/**
 * //from   w w  w .  jav a2s  .c  om
 */
private void updateUI() {
    boolean isRep = mimeTypeCBX.getSelectedIndex() > 0;
    tableIdCBX.setEnabled(isRep);
    reqsRecSetChk.setEnabled(isRep);
    rptTypeCBX.setEnabled(isRep);
    subReportsTxt.setEnabled(isRep);
    actionsTxt.setEnabled(isRep);
    for (JLabel lbl : labels) {
        lbl.setEnabled(isRep);
    }
}

From source file:net.vanosten.dings.swing.SummaryView.java

private void initComponents() {
    chartP = new JPanel();
    chartP.setLayout(new BorderLayout());
    //to begin with we show an information
    JLabel infoL = new JLabel(
            "Choose the chart type belwo and press the \"Update View\" button to show statistics.");
    infoL.setEnabled(false); //only for display
    infoL.setHorizontalAlignment(SwingConstants.CENTER);
    chartP.add(infoL, BorderLayout.CENTER);

    Vector<String> items = new Vector<String>();
    items.add("Entries by " + Toolbox.getInstance().getInfoPointer().getUnitLabel());
    items.add("Entries by " + Toolbox.getInstance().getInfoPointer().getCategoryLabel());
    items.add("Entries by Entry Type");
    items.add("Entries by Score");
    items.add("Entry Scores over Time"); //do not change sequence of elements, as showGraph() and checkChosenStattype rely on it
    chartTypeCB = new JComboBox(items);
    chartTypeCB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (4 == chartTypeCB.getSelectedIndex()) {
                chosenCB.setEnabled(false);
            } else {
                chosenCB.setEnabled(true);
            }//from w w  w .  jav  a2 s .com
        }
    });

    chosenCB = new JCheckBox("Only Selected Entries", false);
    chosenCB.setMnemonic("O".charAt(0));
}

From source file:edu.ku.brc.specify.datamodel.busrules.AgentBusRules.java

/**
 * Enables/Disables both the control and the Label
 * @param id the id of the control//from  w w w. ja  v  a  2 s  . c o m
 * @param enabled enable it
 * @param value the value it should set
 * @param thisObj the main data object
 */
protected void enableFieldAndLabel(final String id, final boolean enabled, final String value,
        final Agent agent) {
    Component field = formViewObj.getCompById(id);
    if (field != null) {
        field.setEnabled(enabled);

        if (field instanceof TextFieldFromPickListTable) {
            String title = "";
            PickListDBAdapterIFace adaptor = ((TextFieldFromPickListTable) field).getPickListAdapter();
            if (adaptor != null) {
                for (PickListItemIFace pli : adaptor.getList()) {
                    if (pli.getValue().equals(value)) {
                        title = pli.getTitle();
                        break;
                    }
                }
                ((TextFieldFromPickListTable) field).setText(title);
            } else {
                log.error("Adapter was null for id [" + id + "] on the Agent Form.");
            }
            return;
        }

        if (field instanceof JComboBox || field instanceof ValComboBox) {
            JComboBox<?> cbx = field instanceof ValComboBox ? ((ValComboBox) field).getComboBox()
                    : (JComboBox<?>) field;
            int inx = -1;
            if (value != null) {
                AbstractListModel<?> model = (AbstractListModel<?>) cbx.getModel();
                for (int i = 0; i < model.getSize(); i++) {
                    Object item = model.getElementAt(i);
                    if (item instanceof PickListItemIFace) {
                        PickListItemIFace pli = (PickListItemIFace) item;
                        if (pli.getValue().equals(value)) {
                            inx = i;
                            break;
                        }
                    } else if (item.toString().equals(value)) {
                        inx = i;
                        break;
                    }
                }
            }
            //System.err.println("AgentBusRules - id "+id+" setting to "+inx);
            cbx.setSelectedIndex(inx);

        } else if (field instanceof JTextComponent) {
            ((JTextComponent) field).setText(value != null ? value : "");

        } else if (field instanceof PartialDateUI) {
            PartialDateUI plugin = (PartialDateUI) field;
            plugin.setValue(agent, null);

        } else {
            log.debug("******** unhandled component type: " + field);
        }
        JLabel label = formViewObj.getLabelFor(field);
        if (label != null) {
            label.setEnabled(enabled);
        }
    }
}

From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java

private RestoreFileWindow(final PReg registry) {
    super();//www  .  ja v a 2 s  .  co m
    setLayout(null);

    final JTextField searchField = new JTextField();
    searchField.setLayout(null);
    searchField.setBounds(2, 2, 301, 26);
    searchField.setBorder(new LineBorder(Color.lightGray));
    searchField.setFont(Constants.FONT);
    add(searchField);

    final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>"
            + "<font color=\"gray\">If you think there is a problem with the<br>"
            + "backup system, please create an issue here:<br>"
            + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>");
    noBackupFilesLabel.setLayout(null);
    noBackupFilesLabel.setBounds(20, 50, 300, 300);
    noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f));
    noBackupFilesLabel.addMouseListener((OnMouseClick) e -> {
        String urlPath = "https://github.com/com.edduarte/protbox/issues";

        try {

            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(new URI(urlPath));

            } else {
                if (SystemUtils.IS_OS_WINDOWS) {
                    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath);

                } else {
                    java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari",
                            "mozilla", "chrome");

                    for (String browser : browsers) {
                        if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) {

                            Runtime.getRuntime().exec(new String[] { browser, urlPath });
                            break;
                        }
                    }
                }
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    });

    DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree();
    final JTree tree = new JTree(rootTreeNode);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    if (rootTreeNode.getChildCount() == 0) {
        searchField.setEnabled(false);
        add(noBackupFilesLabel);
    }
    expandTree(tree);
    tree.setLayout(null);
    tree.setRootVisible(false);
    tree.setEditable(false);
    tree.setCellRenderer(new SearchableTreeCellRenderer(searchField));
    searchField.addKeyListener((OnKeyReleased) e -> {

        // update and expand tree
        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        model.nodeStructureChanged((TreeNode) model.getRoot());
        expandTree(tree);
    });
    final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBorder(new DropShadowBorder());
    scroll.setBorder(new LineBorder(Color.lightGray));
    scroll.setBounds(2, 30, 334, 360);
    add(scroll);

    JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png")));
    close.setLayout(null);
    close.setBounds(312, 7, 18, 18);
    close.setFont(Constants.FONT);
    close.setForeground(Color.gray);
    close.addMouseListener((OnMouseClick) e -> dispose());
    add(close);

    final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png")));
    permanentDeleteButton.setLayout(null);
    permanentDeleteButton.setBounds(91, 390, 40, 39);
    permanentDeleteButton.setBackground(Color.black);
    permanentDeleteButton.setEnabled(false);
    permanentDeleteButton.addMouseListener((OnMouseClick) e -> {
        if (permanentDeleteButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();

            if (JOptionPane.showConfirmDialog(null,
                    "Are you sure you wish to permanently delete '" + entry.realName()
                            + "'?\nThis file and its "
                            + "backup copies will be deleted immediately. You cannot undo this action.",
                    "Confirm Cancel", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {

                registry.permanentDelete(entry);
                dispose();
                RestoreFileWindow.getInstance(registry);

            } else {
                setVisible(true);
            }
        }
    });
    add(permanentDeleteButton);

    final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png")));
    configBackupsButton.setLayout(null);
    configBackupsButton.setBounds(134, 390, 40, 39);
    configBackupsButton.setBackground(Color.black);
    configBackupsButton.setEnabled(false);
    configBackupsButton.addMouseListener((OnMouseClick) e -> {
        if (configBackupsButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;

                JFrame frame = new JFrame("Choose backup policy");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below the backup policy for this file:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(),
                        pbxFile.getBackupPolicy());

                if (option == null) {
                    setVisible(true);
                    return;
                }
                PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString());
                pbxFile.setBackupPolicy(pickedPolicy);
            }
            setVisible(true);
        }
    });
    add(configBackupsButton);

    final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png")));
    restoreBackupButton.setLayout(null);
    restoreBackupButton.setBounds(3, 390, 85, 39);
    restoreBackupButton.setBackground(Color.black);
    restoreBackupButton.setEnabled(false);
    restoreBackupButton.addMouseListener((OnMouseClick) e -> {
        if (restoreBackupButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFolder) {
                registry.restoreFolderFromEntry((PbxFolder) entry);

            } else if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;
                java.util.List<String> snapshots = pbxFile.snapshotsToString();
                if (snapshots.isEmpty()) {
                    setVisible(true);
                    return;
                }

                JFrame frame = new JFrame("Choose backup");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below what backup snapshot would you like restore:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0));

                if (option == null) {
                    setVisible(true);
                    return;
                }
                int pickedIndex = snapshots.indexOf(option.toString());
                registry.restoreFileFromEntry((PbxFile) entry, pickedIndex);
            }
            dispose();
        }
    });
    add(restoreBackupButton);

    tree.addMouseListener((OnMouseClick) e -> {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
        if (node != null) {
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(false);

            } else if (entry instanceof PbxFile) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(true);

            } else {
                permanentDeleteButton.setEnabled(false);
                restoreBackupButton.setEnabled(false);
                configBackupsButton.setEnabled(false);
            }
        }
    });

    final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png")));
    cancel.setLayout(null);
    cancel.setBounds(229, 390, 122, 39);
    cancel.setBackground(Color.black);
    cancel.addMouseListener((OnMouseClick) e -> dispose());
    add(cancel);

    addWindowFocusListener(new WindowFocusListener() {
        private boolean gained = false;

        @Override
        public void windowGainedFocus(WindowEvent e) {
            gained = true;
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            if (gained) {
                dispose();
            }
        }
    });

    setSize(340, 432);
    setUndecorated(true);
    getContentPane().setBackground(Color.white);
    setResizable(false);
    getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100)));
    Utils.setComponentLocationOnCenter(this);
    setVisible(true);
}

From source file:cool.pandora.modeller.ui.jpanel.iiif.UploadBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//  w w w.  j a v  a  2  s . com
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("UploadBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Upload Resources " + "to:")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();
    final DefaultBag bag = bagView.getBag();

    if (bag != null) {
        map = bag.getInfo().getFieldMap();
    }

    final JLabel urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    final JTextField urlField = new JTextField("");
    final URI uri = IIIFObjectURI.getResourceContainerURI(map);
    try {
        urlField.setText(uri != null ? uri.toString() : null);
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    //only if bag is not null
    if (bag != null) {
        urlLabel.setEnabled(true);
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jPanelUserInfo   
 *    //from  w  ww  . j  a  va 2  s. c  om
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelUserInfo() {

    if (jPanelUserInfo == null) {

        jPanelUserInfo = new JPanel();
        jPanelUserInfo.setLayout(new GridBagLayout());

        // User ID
        JLabel jLabelUser = new JLabel("User ID:");
        jLabelUser.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabelUser.setText("User ID :");
        jLabelUser.setEnabled(true);
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new Insets(0, 10, 0, 0);
        jPanelUserInfo.add(jLabelUser, gridBagConstraints);

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.gridx = 1;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.insets = new Insets(5, 5, 5, 5);
        jPanelUserInfo.add(getJTextFieldUser(), gridBagConstraints1);

        // Password
        JLabel jLabelPwd = new JLabel();
        jLabelPwd.setText("Password :");
        jLabelPwd.setHorizontalAlignment(SwingConstants.RIGHT);
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridy = 1;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.insets = new Insets(0, 10, 0, 0);
        jPanelUserInfo.add(jLabelPwd, gridBagConstraints2);

        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.BOTH;
        gridBagConstraints3.gridy = 1;
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.weightx = 1.0;
        gridBagConstraints3.insets = new Insets(5, 5, 5, 5);
        jPanelUserInfo.add(getJPasswordField(), gridBagConstraints3);

        // Protex Server IP
        JLabel jLabelServer = new JLabel();
        jLabelServer.setText("Protex Server IP :");
        jLabelServer.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabelServer.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridy = 2;
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints11.insets = new Insets(0, 10, 5, 0);
        jPanelUserInfo.add(jLabelServer, gridBagConstraints11);

        GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
        gridBagConstraints21.gridy = 2;
        gridBagConstraints21.gridx = 1;
        gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints21.insets = new Insets(5, 5, 10, 5);

        jPanelUserInfo.add(getJTextFieldServerIP(), gridBagConstraints21);
    }
    return jPanelUserInfo;
}

From source file:gui.EventReader.java

@Override
public void run() {

    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10 * 1000).build();
    HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();
    //HttpClient client = new DefaultHttpClient();

    HttpGet request = new HttpGet(
            //"https://api.guildwars2.com/v1/events.json?world_id="
            "http://gw2eventer.sourceforge.net/api/events.php?world_id=" + this.worldID);

    HttpResponse response;/*from   w  ww.  ja  v a 2 s  .c  om*/

    String line = "";
    String out = "";

    while (!isInterrupted()) {

        try {

            this.labelWorking.setText(this.workingString);

            try {

                response = client.execute(request);

                if (response.getStatusLine().toString().contains("200")) {

                    BufferedReader rd = new BufferedReader(
                            new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")));

                    line = "";
                    out = "";

                    while ((line = rd.readLine()) != null) {

                        out = out + line;
                    }
                } else {
                    // http error
                    request.releaseConnection();

                    this.refreshSelector.setEnabled(false);
                    this.workingButton.setEnabled(false);
                    this.jComboBoxLanguage.setEnabled(false);
                    this.labelWorking.setText("connection error. retrying in... 10.");
                    this.labelWorking.setVisible(true);

                    Thread.sleep(10000);
                    continue;
                }
            } catch (IOException | IllegalStateException ex) {

                Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex);

                request.releaseConnection();

                this.refreshSelector.setEnabled(false);
                this.workingButton.setEnabled(false);
                this.jComboBoxLanguage.setEnabled(false);
                this.labelWorking.setText("connection error. retrying in... 10.");
                this.labelWorking.setVisible(true);

                Thread.sleep(10000);
                continue;
                //this.interrupt();
            }

            request.releaseConnection();

            JSONParser parser = new JSONParser();

            Object obj;

            this.result.clear();

            HashMap mehrfachEvents = new HashMap();
            playSoundsList.clear();

            this.overlayGui.clearActive();
            String toolTip;

            try {

                obj = parser.parse(out);

                for (int i = 0; i < this.eventLabels.size(); i++) {

                    JLabel iter = (JLabel) this.eventLabels.get(i);
                    iter.setEnabled(false);
                    iter.setForeground(Color.green);
                }

                for (Iterator iterator = ((JSONObject) obj).values().iterator(); iterator.hasNext();) {

                    JSONArray arrayNew = (JSONArray) iterator.next();

                    for (int i = 0; i < arrayNew.size(); i++) {

                        JSONObject obj2 = (JSONObject) arrayNew.get(i);

                        if (obj2.get("event_id") != null) {

                            String event = (String) obj2.get("event_id");

                            if (this.events.containsKey(event)) {

                                //System.out.println("debug: " + event + "\n");
                                this.result.add(obj2.get("event_id"));

                                int indexEvent = Integer.parseInt(((String[]) this.events.get(event))[0]);
                                String eventPercent = ((String[]) this.events.get(event))[1];
                                String eventWav = ((String[]) this.events.get(event))[2];
                                String eventName = ((String[]) this.events.get(event))[3];

                                JLabel activeLabel = (JLabel) this.eventLabels.get(indexEvent - 1);
                                JLabel activeLabelTimer = (JLabel) this.eventLabelsTimer.get(indexEvent - 1);

                                int activeLabelInt = indexEvent - 1;
                                String tmpEventName = eventPercent.substring(0, 1);

                                Date dateNow = new Date();
                                long stampNow = dateNow.getTime();

                                if (this.timerStamps[activeLabelInt] != null) {

                                    long oldTimestamp = this.timerStamps[activeLabelInt].getTime();
                                    long minsdiff = ((stampNow - oldTimestamp) / 1000 / 60);

                                    if (minsdiff >= 30) {
                                        activeLabelTimer.setEnabled(true);
                                    } else {
                                        activeLabelTimer.setEnabled(false);
                                    }

                                    if (minsdiff >= 60) {
                                        activeLabelTimer.setForeground(Color.red);
                                    } else {
                                        activeLabelTimer.setForeground(Color.green);
                                    }

                                    activeLabelTimer.setText(minsdiff + " mins (B)");
                                }

                                /*
                                if (activeLabel != null) {
                                if (activeLabel.getToolTipText() != null) {
                                    if (activeLabel.getToolTipText().equals("")) { // null pointer??
                                        activeLabel.setToolTipText((String) this.allEvents.get(obj2.get("event_id")));
                                    }
                                }
                                }*/

                                if (obj2.get("state").equals("Active")) {

                                    activeLabel.setEnabled(true);

                                    //activeLabel.setToolTipText((String) this.allEvents.get(obj2.get("event_id")));

                                    toolTip = activeLabel.getToolTipText();

                                    if (toolTip != null) {

                                        if (toolTip.length() > 35) {
                                            toolTip = toolTip.substring(0, 35) + "...";
                                        }
                                    } else {
                                        toolTip = "";
                                    }

                                    if (tmpEventName.equals("B")) {

                                        this.markedBs[activeLabelInt] = true;
                                        activeLabelTimer.setVisible(false);
                                        this.timerStamps[activeLabelInt] = null;

                                        if (this.eventPlaySounds[activeLabelInt][2]) {
                                            if (!this.overlayGui.containsActiveB(eventName)) {
                                                this.overlayGui.addActiveB(eventName, "yellow", activeLabelInt);
                                            }
                                        } else {
                                            if (!this.overlayGui.containsActiveB(eventName)) {
                                                this.overlayGui.addActiveB(eventName, "green", activeLabelInt);
                                            }
                                        }
                                    } else {

                                        if (this.eventPlaySounds[activeLabelInt][2]) {
                                            if (!this.overlayGui.containsActivePre(eventName)) {
                                                this.overlayGui.addActivePreEvent(eventName, "yellow",
                                                        activeLabelInt);
                                            }
                                        } else {
                                            if (!this.overlayGui.containsActivePre(eventName)) {
                                                this.overlayGui.addActivePreEvent(eventName, "green",
                                                        activeLabelInt);
                                            }
                                        }
                                    }

                                    //activeLabel.setSize(100, activeLabel.getSize().height);
                                    //activeLabel.setText(eventPercent);

                                    URL url = this.getClass().getClassLoader()
                                            .getResource("media/sounds/" + eventWav + ".wav");

                                    if (!playSoundsList.containsKey(url)) {

                                        if (!this.eventPlaySounds[activeLabelInt][2]) {
                                            if (tmpEventName.equals("B")) {
                                                if (this.eventPlaySounds[activeLabelInt][1]) {

                                                    playSoundsList.put(url, activeLabel);
                                                }
                                            } else {
                                                if (this.eventPlaySounds[activeLabelInt][0]) {

                                                    playSoundsList.put(url, activeLabel);
                                                }
                                            }
                                        } else {
                                            activeLabel.setForeground(Color.YELLOW);
                                        }
                                    }

                                    if (mehrfachEvents.containsKey(activeLabel)) {
                                        ((ArrayList) mehrfachEvents.get(activeLabel)).add(tmpEventName);
                                    } else {
                                        ArrayList tmpListe = new ArrayList();
                                        tmpListe.add(tmpEventName);
                                        mehrfachEvents.put(activeLabel, tmpListe);
                                    }
                                } else {

                                    if (tmpEventName.equals("B")) {
                                        if (this.markedBs[activeLabelInt]) {

                                            this.timerStamps[activeLabelInt] = dateNow;
                                            this.markedBs[activeLabelInt] = false;

                                            activeLabelTimer.setVisible(true);
                                            activeLabelTimer.setText("0 mins (B)");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Iterator it = mehrfachEvents.entrySet().iterator();

                while (it.hasNext()) {

                    Map.Entry pairs = (Map.Entry) it.next();

                    JLabel label = (JLabel) pairs.getKey();
                    ArrayList liste = (ArrayList) pairs.getValue();
                    String outString = null;

                    Collections.sort(liste, new Comparator<String>() {
                        public int compare(String f1, String f2) {
                            return -f1.toString().compareTo(f2.toString());
                        }
                    });

                    for (int i = 0; i < liste.size(); i++) {

                        if (outString == null) {
                            outString = (String) liste.get(i);
                        } else {
                            outString += ", " + (String) liste.get(i);
                        }
                    }

                    label.setText(outString);

                    it.remove();
                }

                this.labelServer.setOpaque(true);
                this.labelServer.setOpaque(false);
                this.labelServer.setEnabled(false);
                this.labelServer.setText("");
                this.labelServer.setText(this.worldName);

                this.labelWorking.setVisible(false);
                this.refreshSelector.setEnabled(true);
                this.workingButton.setEnabled(true);
                this.jComboBoxLanguage.setEnabled(true);

                this.overlayGui.renderActive();

                if (playSounds) {

                    this.playThread = new Thread() {

                        @Override
                        public void run() {

                            Iterator it = playSoundsList.entrySet().iterator();

                            while (it.hasNext() && !isInterrupted()) {

                                AudioInputStream audioIn;

                                Map.Entry pairs = (Map.Entry) it.next();

                                JLabel label = (JLabel) pairs.getValue();

                                try {

                                    playSoundsCurrent = (URL) pairs.getKey();
                                    audioIn = AudioSystem.getAudioInputStream(playSoundsCurrent);

                                    Clip clip = null;
                                    String tmp = label.getText();

                                    try {
                                        //label.setText(">" + tmp);
                                        //label.setText("<HTML><U>" + tmp + "<U><HTML>");
                                        label.setForeground(Color.red);

                                        //Font font = label.getFont();
                                        //Map attributes = font.getAttributes();
                                        //attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
                                        //label.setFont(font.deriveFont(attributes));

                                        clip = AudioSystem.getClip();
                                        clip.open(audioIn);

                                        clip.start();
                                    } catch (LineUnavailableException ex) {
                                        Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null,
                                                ex);
                                    } finally {
                                        try {
                                            audioIn.close();
                                        } catch (IOException ex) {
                                            Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE,
                                                    null, ex);
                                        }
                                    }

                                    try {
                                        Thread.sleep(2000);
                                        //label.setText(tmp);
                                        label.setForeground(Color.green);
                                    } catch (InterruptedException ex) {
                                        Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null,
                                                ex);
                                        this.interrupt(); //??
                                    }
                                } catch (UnsupportedAudioFileException ex) {
                                    Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex);
                                } catch (IOException ex) {
                                    Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex);
                                }

                                it.remove();
                            }
                        }
                    };

                    this.playThread.start();
                    this.playThread.join();
                }

            } catch (ParseException ex) {

                Logger.getLogger(ApiManager.class.getName()).log(Level.SEVERE, null, ex);

                this.refreshSelector.setEnabled(false);
                this.workingButton.setEnabled(false);
                this.jComboBoxLanguage.setEnabled(false);
                this.labelWorking.setText("connection error. retrying in... 10.");
                this.labelWorking.setVisible(true);

                Thread.sleep(10000);
                continue;
            }

            if (this.autoRefresh) {

                Thread.sleep(this.sleepTime * 1000);
            } else {

                this.interrupt();
            }
        } catch (InterruptedException ex) {

            Logger.getLogger(ApiManager.class.getName()).log(Level.SEVERE, null, ex);

            this.interrupt();
        }
    }
}