Example usage for javax.swing JLabel getText

List of usage examples for javax.swing JLabel getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Returns the text string that the label displays.

Usage

From source file:edu.ku.brc.af.ui.forms.validation.FormValidator.java

/**
 * Returns the Text of the label for a control's Id (strips ':' from end of string)
 * @param id the unique identifier// w ww.  j a  v a2 s. co m
 * @return the text of the label
 */
public String getLabelTextForId(final String id) {
    JLabel label = labels.get(id);
    if (label != null) {
        String labelStr = label.getText();
        if (labelStr.endsWith(":")) {
            return labelStr.substring(0, labelStr.length() - 1);
        }
        return labelStr;
    }
    return "";
}

From source file:generadorqr.jifrNuevoQr.java

void CargarVideo(JLabel label, Integer identificador) {
    int resultado;
    // ventana = new CargarFoto();
    JFileChooser jfchCargarVideo = new JFileChooser();
    FileNameExtensionFilter filtro = new FileNameExtensionFilter("MP4", "mp4");
    jfchCargarVideo.setFileFilter(filtro);
    resultado = jfchCargarVideo.showOpenDialog(null);
    if (JFileChooser.APPROVE_OPTION == resultado) {
        fichero = jfchCargarVideo.getSelectedFile();
        try {//from  w  w  w  .  jav a2  s.c  o  m
            tempVideo = fichero.getPath();
            tempNombreMultimedia[identificador] = fichero.getName();
            label.setText(tempNombreMultimedia[identificador]);
            if (label.getText().length() > 10)
                label.setText(tempNombreMultimedia[identificador].substring(0, 10) + "...mp4");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error abriendo la imagen" + ex);
        }
    }
}

From source file:generadorqr.jifrNuevoQr.java

void CargarAudio(JLabel label, Integer identificador) {
    int resultado;
    // ventana = new CargarFoto();
    JFileChooser jfchCargarVideo = new JFileChooser();
    FileNameExtensionFilter filtro = new FileNameExtensionFilter("MP3", "mp3");
    jfchCargarVideo.setFileFilter(filtro);
    resultado = jfchCargarVideo.showOpenDialog(null);
    if (JFileChooser.APPROVE_OPTION == resultado) {
        fichero = jfchCargarVideo.getSelectedFile();
        try {//w  w  w  .j  ava2s  .c om
            tempAudio = fichero.getPath();
            tempNombreMultimedia[identificador] = fichero.getName();
            label.setText(tempNombreMultimedia[identificador]);
            if (label.getText().length() > 10)
                label.setText(tempNombreMultimedia[identificador].substring(0, 10) + "...mp3");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error abriendo la imagen" + ex);
        }
    }
}

From source file:Interfaz.rubiktimer.java

private void funcionalidad_botones(JLabel nuev_tiempo, JLabel scrambl, JButton elim, JButton penaliz,
        JButton dnf) {/* w w  w  . j a  va2 s.  co m*/

    elim.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            System.out.println("///" + nuev_tiempo.getText() + "///");
            listaT.eliminar(tiempo, nuev_tiempo.getText());
            lista5mej.eliminar(tiempo, nuev_tiempo.getText());
            lista10mej.eliminar(tiempo, nuev_tiempo.getText());
            //lista5mej.actualizar5(lista5mej,listaT);
            //lista10mej.actualizar10(lista10mej,listaT);
            panel.remove(nuev_tiempo);
            panel.remove(scrambl);
            panel.remove(penaliz);
            panel.remove(elim);
            panel.remove(dnf);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();

        }

    });
    penaliz.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            lista5mej.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            listaT.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            lista10mej.penalizacion(nuev_tiempo, nuev_tiempo.getText());
            penaliz.setEnabled(false);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();
        }

    });
    dnf.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            listaT.eliminar(tiempo, nuev_tiempo.getText());
            lista5mej.eliminar(tiempo, nuev_tiempo.getText());
            lista10mej.eliminar(tiempo, nuev_tiempo.getText());
            nuev_tiempo.setEnabled(false);
            scrambl.setEnabled(false);
            elim.setEnabled(false);
            penaliz.setEnabled(false);
            dnf.setEnabled(false);
            actualizar_estad();
            actualizarGrafica();
            panel.updateUI();
        }

    });

}

From source file:de.main.sessioncreator.DesktopApplication1View.java

private void cleanupReviewPanel() {
    for (int i = 0; i < reviewCmbxSessiontoReview.getItemCount(); i++) {
        if (reviewCmbxSessiontoReview.getItemAt(i)
                .equals(reviewCmbxSessiontoReview.getSelectedItem().toString())) {
            reviewCmbxSessiontoReview.removeItemAt(i);
            break;
        }//from w w  w. jav a 2  s.com
    }
    reviewCmbxSessiontoReview.setSelectedIndex(0);
    Component[] compo = reviewtoReviewPanel.getComponents();
    for (Component c : compo) {
        if (c instanceof JLabel) {
            JLabel jl = (JLabel) c;
            if (jl.getText().contains(reviewtfNameOfTester.getText())) {
                char nc;
                String text = jl.getText();
                nc = text.charAt(jl.getText().lastIndexOf(":") + 2);
                int no = Character.digit(nc, 10);
                no--;
                jl.setText(text.replace(text.charAt(text.lastIndexOf(":") + 2), Character.forDigit(no, 10)));
                reviewtoReviewPanel.revalidate();
                reviewtoReviewPanel.repaint();
                break;
            }
        }
    }
    reviewtaCharterdynamic.setText("");
    reviewtaTestsessionAreasReview.setText("");
    reviewLblStartTime.setText("");
    reviewtfNameOfTester.setText("");
    reviewtfDuration.setText("");
    reviewtfSessionSetup.setText("");
    reviewtfTestDesignExecution.setText("");
    reviewtfBugInvestigation.setText("");
    reviewtfCharter.setText("");
    reviewtaDataFiles.setText("");
    reviewtaTestNotes.setText("");
    reviewedipaneBugs.setText("");
    reviewtaIssues.setText("");
    reviewtaReview.setText("");
}

From source file:Creator.WidgetPanel.java

private void _List_WidgetCodeListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event__List_WidgetCodeListValueChanged

    // _ScrollPane_WidgetSettings
    if (!evt.getValueIsAdjusting()) {

        // Load the variables of the widget
        String widgetCodeStr;//from  w  w w.j  a  v a2 s .co m
        WidgetCode wc = null;
        WidgetLink wl = null;
        if (!_JTree_WidgetLinks.isSelectionEmpty()) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) _JTree_WidgetLinks
                    .getLastSelectedPathComponent();

            if (node == null) //Nothing is selected.  
            {
                return;
            }

            if (node.getParent() != null) {
                String s = node.getParent().toString() + "-" + node.getUserObject().toString();

                if (ws.containsKey(s)) {
                    wl = ws.get(s);
                    wc = widgetList.get(wl.getWidgetCodeName());
                }
            }
        }

        if (wc == null) {
            // No selected item on the JTree
            widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
            wc = widgetList.get(widgetCodeStr);
        } else {

            // Make sure the item selected matches the code in the widget link
            // This makes selecting 
            if (!wc.getWidgetName().equals(_List_WidgetCodeList.getSelectedValue().toString())) {

                widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
                wc = widgetList.get(widgetCodeStr);
            }

        }

        GridBagLayout gbl = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.ipadx = 0;
        c.ipady = 5;

        if (widgetCodeSettings == null) {
            widgetCodeSettings = new HashMap<>();
        } else {
            widgetCodeSettings.clear();
        }

        _Panel_WidgetSettings.removeAll();
        _Panel_WidgetSettings.setLayout(gbl);

        for (String name : wc.getVariables()) {
            JLabel label = new JLabel(name);
            label.setFont(new Font("Arial", Font.BOLD, 13));
            label.setHorizontalAlignment(SwingConstants.CENTER);
            JTextField textfield = new JTextField("");
            textfield.setHorizontalAlignment(SwingConstants.CENTER);
            if (wl != null) {
                textfield.setText(wl.getVariables().get(name));
            }

            textfield.setFont(new Font("Arial", Font.BOLD, 15));

            widgetCodeSettings.put(label.getText(), textfield);
            _Panel_WidgetSettings.add(label, c);
            c.gridy += 1;
            _Panel_WidgetSettings.add(textfield, c);
            c.gridy += 1;
        }

        _ScrollPane_WidgetSettings.revalidate();
        _ScrollPane_WidgetSettings.repaint();

    }

}

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 w  w  .j  a  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();
        }
    }
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * @param pb//w ww  . j  ava 2 s .  c  o m
 * @param label
 * @param cc
 * @param items
 */
private void addLabel(final ArrayList<String> items, final PanelBuilder pb, final JLabel label,
        final CellConstraints cc) {
    if (label != null && items != null && pb != null && cc != null) {
        pb.add(label, cc);
        String text = label.getText();
        items.add(StringUtils.remove(text != null ? text.trim() : "", ":"));
    } else {
        log.error("Error adding label.");
    }
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from  w ww .j a  v a2 s.  c om*/
 *
 * @param pt1 _more_
 *
 * @throws Exception _more_
 */
protected void processReadout(FlythroughPoint pt1) throws Exception {

    Font font = new Font("Dialog", Font.BOLD, 22);
    dials = new ArrayList<JComponent>();
    if ((readoutLabel == null) || (pt1 == null)) {
        return;
    }

    List<ReadoutInfo> samples = new ArrayList<ReadoutInfo>();
    readoutLabel.setText(readout.getReadout(pt1.getEarthLocation(), showReadout, true, samples));

    if (!showReadout) {
        return;
    }

    List comps = new ArrayList();
    for (FlythroughDecorator decorator : decorators) {
        decorator.handleReadout(pt1, samples);
    }

    for (ReadoutInfo info : samples) {
        Real r = info.getReal();
        if (r == null) {
            continue;
        }

        Unit unit = info.getUnit();
        if (unit == null) {
            unit = r.getUnit();
        }
        String name = ucar.visad.Util.cleanTypeName(r.getType());

        String unitSuffix = "";
        if (unit != null) {
            unitSuffix = " [" + unit + "]";
        }

        double v = r.getValue(unit);
        if (v == v) {
            v = Misc.parseNumber(Misc.format(v));
        }

        JLabel label = new JLabel(name.replace("_", " "));

        label.setFont(font);
        DefaultValueDataset dataset = new DefaultValueDataset(new Double(v));
        MeterPlot plot = new MeterPlot(dataset);
        if (info.getRange() != null) {
            Range range = info.getRange();
            plot.setRange(new org.jfree.data.Range(range.getMin(), range.getMax()));
        }
        if (unit != null) {
            plot.setUnits(unit.toString());
        } else {
            plot.setUnits("");
        }
        plot.setDialBackgroundPaint(Color.white);
        plot.setTickLabelsVisible(true);
        plot.setValueFont(font);
        plot.setTickLabelFont(font);
        plot.setTickLabelPaint(Color.darkGray);
        plot.setTickPaint(Color.black);
        plot.setValuePaint(Color.black);

        JFreeChart chart = new JFreeChart("", plot);
        TextTitle title = new TextTitle(" " + label.getText() + " ", font);
        title.setBackgroundPaint(Color.gray);
        title.setPaint(Color.white);
        chart.setTitle(title);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(dialDimension);
        chartPanel.setSize(new Dimension(150, 150));
        plot.setBackgroundPaint(new Color(255, 255, 255, 0));
        plot.setBackgroundImageAlpha(0.0f);
        chart.setBackgroundPaint(new Color(255, 255, 255, 0));
        chartPanel.setBackground(new Color(255, 255, 255, 0));
        comps.add(chartPanel);
        dials.add(chartPanel);
    }

    readoutDisplay.removeAll();
    updateDashboard();

}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

/**
 * Show result frame for calculated attacks
 *//*from  w  w w  . j  a v a  2 s .  c  o m*/
private void showResults(List<Attack> pAttacks) {
    mLogFrame.setVisible(false);
    jResultsTable.invalidate();
    DefaultTableModel resultModel = new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Herkunft", "Einheit", "Ziel", "Start", "Ankunft", "Typ", "" }) {

        Class[] types = new Class[] { Village.class, UnitHolder.class, Village.class, Date.class, Date.class,
                Integer.class, Boolean.class };

        @Override
        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return false;
        }
    };

    //renderer, which marks send times red if attack is impossible to send
    DefaultTableRenderer renderer = new DefaultTableRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Component c = new DateCellRenderer().getTableCellRendererComponent(table, value, isSelected,
                    hasFocus, row, column);
            JLabel l = (JLabel) c;
            Boolean impossible = (Boolean) table.getModel().getValueAt(row, 6);
            if (impossible.booleanValue()) {
                l.setText("<html><nobr><font color='#FF0000'>" + l.getText() + "</font></nobr></html>");
            }
            return c;
        }
    };

    jResultsTable.setDefaultRenderer(Date.class, renderer);
    jResultsTable.setDefaultRenderer(Integer.class,
            new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    jResultsTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE));
    jResultsTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jResultsTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor());
    jResultsTable.setDefaultRenderer(Village.class, new VillageCellRenderer());
    jResultsTable.setRowHeight(24);
    List<Long> startTimes = new LinkedList<Long>();
    int impossibleAttacks = 0;

    for (Attack a : pAttacks) {
        long targetTime = a.getArriveTime().getTime();
        long startTime = targetTime - (long) (DSCalculator.calculateMoveTimeInSeconds(a.getSource(),
                a.getTarget(), a.getUnit().getSpeed()) * 1000);
        boolean impossible = false;
        if (!startTimes.contains(startTime)) {
            startTimes.add(startTime);
        } else {
            impossibleAttacks++;
            impossible = true;
        }
        resultModel.addRow(new Object[] { a.getSource(), a.getUnit(), a.getTarget(), new Date(startTime),
                a.getArriveTime(), a.getType(), impossible });
    }

    jResultsTable.setModel(resultModel);

    TableColumnExt columns = jResultsTable.getColumnExt(5);
    columns.setVisible(false);
    jResultsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());

    jResultFrame.setVisible(true);

    if (impossibleAttacks > 0) {
        String message = "";
        if (impossibleAttacks == 1) {
            message = "<html>Ein berechneter Angriff hat einen bereits verwendeten Abschickzeitpunkt.<br/>Der entsprechende Angriff ist in der Tabelle rot markiert</html>";
        } else {
            message = "<html>" + impossibleAttacks
                    + " berechnete Angriffe haben identische Abschickzeitpunkte.<br/>Die entsprechenden Angriffe sind in der Tabelle rot markiert</html>";
        }
        showInfo(message, true);
    }
}