Example usage for java.awt Label setText

List of usage examples for java.awt Label setText

Introduction

In this page you can find the example usage for java.awt Label setText.

Prototype

public void setText(String text) 

Source Link

Document

Sets the text for this label to the specified text.

Usage

From source file:SimpleInputMethod.java

public void setInputMethodContext(InputMethodContext context) {
    inputMethodContext = context;/*  w ww .  j a v a 2 s .c o m*/
    if (statusWindow == null) {
        statusWindow = context.createInputMethodWindow("Simple Input Method", false);
        Label label = new Label();
        label.setText(locale.getDisplayName());
        statusWindow.add(label);
        label.setSize(200, 50);
        statusWindow.add(label);
        statusWindow.pack();

        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        statusWindow.setLocation(d.width - statusWindow.getWidth(), d.height - statusWindow.getHeight());
    }
}

From source file:Presentation.MainWindow.java

/** Update des valeurs de temprature et d'humidit en temps rel */
public void updateLiveValues(float temperature, float humidite, boolean condense) {

    Component[] labels = this.tPanel.getComponents();

    if (labels.length > 0) {

        if (labels[0] instanceof Label) {
            Label nLabelTemp = (Label) labels[0];
            nLabelTemp.setText("Temprature du frigo : " + temperature + " C");
        }/*from w w w . j  a v  a 2 s.c  o  m*/

        if (labels[1] instanceof Label) {
            Label nLabelTemp = (Label) labels[1];
            nLabelTemp.setText(
                    "Temprature extrieure : " + Singleton.getInstance().getMock().getOutdoorTemp() + " C");
        }

        if (labels[2] instanceof Label) {
            Label nLabelHumid = (Label) labels[2];
            nLabelHumid.setText("Humidit  l'intrieur du frigo : " + humidite + " %");
        }

        if (labels[3] instanceof Label) {
            Label nLabelCondense = (Label) labels[3];
            if (!condense)
                nLabelCondense.hide();
            else
                nLabelCondense.show();
        }
        show();
    } else
        showLiveValues(temperature, humidite, condense);
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploaderThumbnailerTester_2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }//from   w w w  . j av  a 2  s  . c o  m

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}

From source file:edu.cornell.mannlib.vitro.webapp.imageprocessor.jai.JaiImageProcessorTester2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }/*from w w w .  ja  v  a2 s  . co  m*/

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new javax.media.jai.widget.ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}

From source file:gdsc.utils.HSB_Picker.java

private void setSliderLabel(final Scrollbar sliderField, final Label sliderLabel, double scale) {
    double value = sliderField.getValue() / scale;
    sliderLabel.setText(String.format("%.2f", value));
}

From source file:gdsc.utils.HSB_Picker.java

private void createLabelPanel(Label labelField, String label, String value) {
    Label listLabel = new Label(label, 0);
    add(listLabel, 0, 1);//  w ww .j  av a 2  s . c  o m
    if (labelField != null) {
        // labelField.setSize(fontWidth * 3, fontWidth);
        labelField.setText(value);
        add(labelField, 1, 2);
    }
    row++;
}

From source file:gdsc.smlm.ij.plugins.SpotAnalysis.java

private Panel createLabelPanel(Label field, String label, String value) {
    Panel panel = new Panel();
    panel.setLayout(new BorderLayout());
    Label listLabel = new Label(label, 0);
    //listLabel.setFont(monoFont);
    //textField.setSize(fontWidth * 3, fontWidth);
    field.setText(value);
    panel.add(listLabel, BorderLayout.WEST);
    panel.add(field, BorderLayout.CENTER);
    return panel;
}

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);/* ww  w .j  a  v a2 s  .  co  m*/
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}