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:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

/**
 * getBagInfoMap.// w  w  w  .  j av a2 s .  c o m
 *
 * @return map
 */
public HashMap<String, String> getBagInfoMap() {
    final HashMap<String, String> map = new HashMap<>();
    String key = "";
    String value = "";
    final Component[] components = getFieldComponents();
    for (int i = 0; i < components.length; i++) {
        Component c;
        c = components[i];
        if (c instanceof JLabel) {
            final JLabel label = (JLabel) c;
            key = label.getText();
        }
        i++;
        // Is required component
        c = components[i];
        i++;
        c = components[i];
        if (c instanceof JTextField) {
            final JTextField tf = (JTextField) c;
            value = tf.getText();
        } else if (c instanceof JTextArea) {
            final JTextArea ta = (JTextArea) c;
            value = ta.getText();
        } else if (c instanceof JComboBox) {
            final JComboBox<?> tb = (JComboBox<?>) c;
            value = (String) tb.getSelectedItem();
        }
        map.put(key, value);
        i++;
        c = components[i];
    }
    return map;
}

From source file:com.willwinder.universalgcodesender.uielements.panels.MachineStatusPanel.java

private void setPostionValueColor(JLabel label, double newValue) {
    if (!label.getText().equals(decimalFormatter.format(newValue))) {
        label.setForeground(Color.red);
    } else {/*w ww .  j a va  2  s.co m*/
        label.setForeground(Color.black);
    }
}

From source file:LDAPTest.java

public Attributes getEditedAttributes() {
        Attributes attrs = new BasicAttributes();
        for (int i = 0; i < getComponentCount(); i += 2) {
            JLabel idLabel = (JLabel) getComponent(i);
            JTextField valueField = (JTextField) getComponent(i + 1);
            String id = idLabel.getText();
            String value = valueField.getText();
            if (id.equals("userPassword"))
                attrs.put("userPassword", value.getBytes());
            else if (!id.equals("") && !id.equals("objectClass"))
                attrs.put(id, value);/* ww w  .j  a  va2  s .  com*/
        }
        return attrs;
    }

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel.java

private JComponent buildToolbar() {
    JXToolBar toolBar = UISupport.createToolbar();
    JButton runButton = UISupport.createToolbarButton(runAction);
    toolBar.add(runButton);/*from w w w . j  av  a2 s .c  om*/
    toolBar.add(Box.createHorizontalGlue());
    JLabel label = new JLabel("<html>Script is invoked with <code>log</code>, <code>context</code> "
            + "and <code>testRunner</code> variables</html>");
    label.setToolTipText(label.getText());
    label.setMaximumSize(label.getPreferredSize());

    toolBar.add(label);
    toolBar.addRelatedGap();
    toolBar.add(UISupport.createToolbarButton(new ShowOnlineHelpAction(HelpUrls.GROOVYSTEPEDITOR_HELP_URL)));

    componentEnabler.add(runButton);

    return toolBar;
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

void filter(String text) {
    this.removeAll();
    int cg = 1;/*from  w  ww  .  ja va  2s .c  o m*/
    for (JLabel lGroup : grpLabels) {
        List<JCheckBox> cbList = cbFilter(lGroup.getText(), text);
        if (!cbList.isEmpty()) {
            this.add(lGroup, constraintsForGroupLabel(cg++ == 0));
            int cd = 1;
            for (JCheckBox cb : cbList) {
                if (cd++ % 2 == 0) {
                    this.add(cb, constraintsForSecondColumnCheckbox());
                } else {
                    this.add(cb, constraintsForFirstColumnCheckbox());
                }
            }
        }
    }
    this.revalidate();
    this.repaint();
}

From source file:com.smanempat.controller.ControllerClassification.java

public void showChart(JLabel jumlahSiswaIPA, JLabel jumlahSiswaIPS, JLabel labelKeterangan) {
    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPA.getText()), "IPA", "IPA");
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPS.getText()), "IPS", "IPS");
    JFreeChart barchart = ChartFactory.createBarChart3D(
            "Grafik Jumlah Siswa per Jurusan, Tahun Ajaran " + labelKeterangan.getText().substring(53, 62) + "",
            "Jurusan", "Jumlah Siswa", barChartData, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plotBarChart = barchart.getCategoryPlot();
    ChartFrame chartFrame = new ChartFrame("Grafik Jumlah Siswa Tiap Jurusan", barchart, true);
    chartFrame.setVisible(true);// www  . ja va2s  . com
    chartFrame.setSize(700, 500);
    chartFrame.setLocationRelativeTo(null);
    plotBarChart.setRangeGridlinePaint(java.awt.Color.black);
    ChartPanel chartPanel = new ChartPanel(barchart);
}

From source file:edu.harvard.i2b2.query.QueryTopPanel.java

private void jAndOrLabelMouseClicked(java.awt.event.MouseEvent evt) {
    JLabel label = (JLabel) evt.getSource();
    if (label.getText().equalsIgnoreCase("and")) {
        label.setText("or");
    } else if (label.getText().equalsIgnoreCase("or")) {
        label.setText("and");
    }/*  w w  w. j a  va 2 s  .c o m*/
}

From source file:net.linra.AttendanceSystemFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    JLabel[] labels = { student1, student2, student3, student4, student5, student6, student7, student8,
            student9, student10, student11, student12, student13, student14, student15, student16, student17,
            student18, student19, student20, student21, student22, student23, student24, student25 };
    if (jList1.getModel().getSize() <= 0) {
        this.jButton1.setEnabled(false);
    } else {/* ww  w .ja  v a 2  s.  c o  m*/
        int i = studentCombobox.getSelectedIndex();
        String name = studentCombobox.getSelectedItem().toString();

        for (JLabel label : labels) {
            if (name.equals(label.getText())) {
                label.setIcon(
                        new javax.swing.ImageIcon(getClass().getResource("/net/linra/picpackage/present.png")));
            }
        }

        this.absentNumber.setText((jList1.getModel().getSize() - 1) + "");
        DefaultListModel model = (DefaultListModel) jList1.getModel();
        model.removeElementAt(i);
        DefaultComboBoxModel model2 = (DefaultComboBoxModel) studentCombobox.getModel();
        model2.removeElementAt(i);

        jPanel4.removeAll();
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.setValue(4, "", "Last Month");
        dataset.setValue(7, "", "Last Week");
        dataset.setValue(3, "", "Yesterday");
        dataset.setValue(Integer.parseInt(this.absentNumber.getText()), "", "Today");
        JFreeChart chart = ChartFactory.createBarChart("Histgram of absent student", "Data", "Absent number",
                dataset, PlotOrientation.VERTICAL, true, true, false);
        ChartPanel p = new ChartPanel(chart);
        p.setSize(jPanel4.getWidth(), jPanel4.getHeight());
        p.setVisible(true);
        jPanel4.add(p);
        jPanel4.repaint();
    }
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

private <T extends JComponent> T append(String name, JComponent label, T component, String alignments,
        int column, int columnSpan) {
    int spaceRowIndex = -1;

    if (rowSpacing > 0 && appended) {
        addSpace(rowSpacing);//from w w  w  .  j  a  va 2  s.  c  o m
        spaceRowIndex = layout.getRowCount();
    }

    layout.appendRow(rowSpec);
    int row = layout.getRowCount();

    if (label != null) {
        panel.add(label, cc.xy(DEFAULT_LABEL_COLUMN, row));
        component.addComponentListener(new LabelHider(label, spaceRowIndex));
        component.addPropertyChangeListener(ENABLED_PROPERTY_NAME, new LabelEnabler(label));

        if (label instanceof JLabel) {
            JLabel jl = ((JLabel) label);
            jl.setLabelFor(component);
            String text = jl.getText();
            int ix = text.indexOf('&');
            if (ix >= 0) {
                jl.setText(text.substring(0, ix) + text.substring(ix + 1));
                jl.setDisplayedMnemonicIndex(ix);
                jl.setDisplayedMnemonic(text.charAt(ix + 1));
            }

            if (component.getAccessibleContext() != null) {
                component.getAccessibleContext().setAccessibleName(text);
            }
        }
    } else {
        component.addComponentListener(new LabelHider(null, spaceRowIndex));
    }

    addComponentToRow(name, component, alignments, column, row, columnSpan);

    return component;
}