Example usage for java.awt Label Label

List of usage examples for java.awt Label Label

Introduction

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

Prototype

public Label(String text) throws HeadlessException 

Source Link

Document

Constructs a new label with the specified string of text, left justified.

Usage

From source file:Presentation.MainWindow.java

/** Ajout  la fentre des valeurs de temprature et d'humidit en temps rel */
public void showLiveValues(float temperature, float humidite, boolean condense) {
    Panel panel = new Panel();
    Label labelTemp = new Label("Temprature du frigo : " + temperature + " C");
    Label labelOutdoorTemp = new Label(
            "Temprature extrieure : " + Singleton.getInstance().getMock().getOutdoorTemp() + " C");
    Label labelHumid = new Label("Humidit  l'intrieur du frigo : " + humidite + " %");
    Label condensation = new Label("Alerte de condensation");

    condensation.setForeground(Color.red);

    //  addCondensation();
    panel.setLayout(new FlowLayout());
    panel.add(labelTemp);/*from w  w w .  j a v a 2 s .co m*/
    panel.add(labelOutdoorTemp);
    panel.add(labelHumid);
    if (condense)
        panel.add(condensation);
    else {
        panel.add(condensation);
        condensation.hide();
    }
    //  panel.add(cLabel);

    this.tPanel = panel;
    mPanel.add(panel);

    show();
}

From source file:LowPassFilterTest.java

@Test
public void test() throws InterruptedException {
    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);//from  ww  w.  java2  s.c o  m
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    double[] data = math.convolve(
            math.HammingWindow(testData.get1DPolyharmSignal(4, 200, frameWidth, discretization), frameWidth),
            math.lpf(60, step, 1024));
    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:CardLayDemo1.java

public void init() {

    panel = new Panel();
    cardlay = new CardLayout();
    b1 = new Button("Next");
    b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (++cardno >= NCARDS)
                cardno = 0;//  www. j  a v  a 2s  .c om
            cardlay.show(panel, labels[cardno]);
        }
    });
    labels[0] = "Card One";
    labels[1] = "Card Two";
    labels[2] = "Card Three";
    labels[3] = "Card Four";

    panel.setLayout(cardlay);
    for (int i = 0; i < NCARDS; i++)
        panel.add(labels[i], new Label(labels[i]));
    cardlay.show(panel, labels[0]);

    setLayout(new BorderLayout());
    add("Center", panel);
    add("South", b1);
}

From source file:MultipartViewer.java

protected void setupDisplay(Multipart mp) {
    // we display the first body part in a main frame on the left, and then
    // on the right we display the rest of the parts as attachments

    GridBagConstraints gc = new GridBagConstraints();
    gc.gridheight = GridBagConstraints.REMAINDER;
    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1.0;/*from  w ww. j a v a2s .c  o  m*/
    gc.weighty = 1.0;

    // get the first part
    try {
        BodyPart bp = mp.getBodyPart(0);
        Component comp = getComponent(bp);
        add(comp, gc);

    } catch (MessagingException me) {
        add(new Label(me.toString()), gc);
    }

    // see if there are more than one parts
    try {
        int count = mp.getCount();

        // setup how to display them
        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.gridheight = 1;
        gc.fill = GridBagConstraints.NONE;
        gc.anchor = GridBagConstraints.NORTH;
        gc.weightx = 0.0;
        gc.weighty = 0.0;
        gc.insets = new Insets(4, 4, 4, 4);

        // for each one we create a button with the content type
        for (int i = 1; i < count; i++) { // we skip the first one 
            BodyPart curr = mp.getBodyPart(i);
            String label = null;
            if (label == null)
                label = curr.getFileName();
            if (label == null)
                label = curr.getDescription();
            if (label == null)
                label = curr.getContentType();

            Button but = new Button(label);
            but.addActionListener(new AttachmentViewer(curr));
            add(but, gc);
        }

    } catch (MessagingException me2) {
        me2.printStackTrace();
    }

}

From source file:GetOpenProperties.java

public void init() {
    //Set up the layout.
    GridBagLayout gridbag = new GridBagLayout();
    setLayout(gridbag);//from w w  w  .ja  v  a 2 s. c  o m
    GridBagConstraints labelConstraints = new GridBagConstraints();
    GridBagConstraints valueConstraints = new GridBagConstraints();
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.ipadx = 10;
    valueConstraints.fill = GridBagConstraints.HORIZONTAL;
    valueConstraints.gridwidth = GridBagConstraints.REMAINDER;
    valueConstraints.weightx = 1.0; //Extra space to values column.

    //Set up the Label arrays.
    Label[] names = new Label[numProperties];
    values = new Label[numProperties];
    String firstValue = "not read yet";

    for (int i = 0; i < numProperties; i++) {
        names[i] = new Label(propertyNames[i]);
        gridbag.setConstraints(names[i], labelConstraints);
        add(names[i]);

        values[i] = new Label(firstValue);
        gridbag.setConstraints(values[i], valueConstraints);
        add(values[i]);
    }

    new Thread(this, "Loading System Properties").start();
}

From source file:layout.GridLayoutDemo.java

public void addComponentsToPane(final Container pane) {
    initGaps();/*from   ww w. j  ava 2 s  . co m*/
    final JPanel compsToExperiment = new JPanel();
    compsToExperiment.setLayout(experimentLayout);
    JPanel controls = new JPanel();
    controls.setLayout(new GridLayout(2, 3));

    //Set up components preferred size
    JButton b = new JButton("Just fake button");
    Dimension buttonSize = b.getPreferredSize();
    compsToExperiment.setPreferredSize(new Dimension((int) (buttonSize.getWidth() * 2.5) + maxGap,
            (int) (buttonSize.getHeight() * 3.5) + maxGap * 2));

    //Add buttons to experiment with Grid Layout
    compsToExperiment.add(new JButton("Button 1"));
    compsToExperiment.add(new JButton("Button 2"));
    compsToExperiment.add(new JButton("Button 3"));
    compsToExperiment.add(new JButton("Long-Named Button 4"));
    compsToExperiment.add(new JButton("5"));

    //Add controls to set up horizontal and vertical gaps
    controls.add(new Label("Horizontal gap:"));
    controls.add(new Label("Vertical gap:"));
    controls.add(new Label(" "));
    controls.add(horGapComboBox);
    controls.add(verGapComboBox);
    controls.add(applyButton);

    //Process the Apply gaps button press
    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //Get the horizontal gap value
            String horGap = (String) horGapComboBox.getSelectedItem();
            //Get the vertical gap value
            String verGap = (String) verGapComboBox.getSelectedItem();
            //Set up the horizontal gap value
            experimentLayout.setHgap(Integer.parseInt(horGap));
            //Set up the vertical gap value
            experimentLayout.setVgap(Integer.parseInt(verGap));
            //Set up the layout of the buttons
            experimentLayout.layoutContainer(compsToExperiment);
        }
    });
    pane.add(compsToExperiment, BorderLayout.NORTH);
    pane.add(new JSeparator(), BorderLayout.CENTER);
    pane.add(controls, BorderLayout.SOUTH);
}

From source file:interpolation.InterpolantFileChooser.java

public InterpolantFileChooser() {

    final JFrame frame = new JFrame("Welcome to the Regression fits");

    Track = new JButton("Choose file");

    panelCont.add(panelIntro, "1");
    /* Instantiation */
    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints c = new GridBagConstraints();

    panelIntro.setLayout(layout);/*w w w  . j a v  a2  s. c  o  m*/

    final Label LoadtrackText = new Label("Input the .txt file of time-series");

    LoadtrackText.setBackground(new Color(1, 0, 1));
    LoadtrackText.setForeground(new Color(255, 255, 255));
    final Checkbox Simplemode = new Checkbox("Open simple time-series file", Simplefile);
    /* Location */

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1.5;

    ++c.gridy;
    c.insets = new Insets(10, 10, 10, 0);
    panelIntro.add(LoadtrackText, c);

    ++c.gridy;
    c.insets = new Insets(10, 10, 10, 0);
    panelIntro.add(Track, c);

    panelIntro.setVisible(true);
    Track.addActionListener(new OpenTrackListener(frame));
    Simplemode.addItemListener(new SimpleListener(frame));
    frame.addWindowListener(new FrameListener(frame));
    frame.add(panelCont, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

}

From source file:BenchmarkApplet.java

public void init() {
      tgroup = Thread.currentThread().getThreadGroup();

      Font font = new Font("Courier", Font.PLAIN, 10);
      FontMetrics fm = getFontMetrics(font);
      int lines = Math.max(10, size().height / fm.getHeight() - 4);

      out = new TextArea(lines, spaces.length() + Benchmark.resolutionName.length());
      out.setFont(font);/*from  ww w .  j a  v a 2  s . c om*/
      out.setEditable(false);
      add(out);

      boolean toobig;
      do {
          testList = new List(--lines, true);
          add(testList, 0);
          validate();
          if (toobig = testList.size().height - out.size().height > 2)
              remove(testList);
      } while (toobig);
      for (int ii = 0; ii < tests.length; ii++)
          testList.addItem(tests[ii].getName());
      testList.select(0); // Calibration benchmark
      testList.select(1); // Mixed benchmark

      timeEstimate = new Label(getTimeEstimate());
      add(timeEstimate);

      add(doit = new Button("Run Benchmark"));
      add(abort = new Button("Stop"));
      add(clear = new Button("Clear"));
      abort.disable();
      clear.disable();

      add(console = new Checkbox("Console"));

      validate();
  }

From source file:Align_Projections.java

public void run(String arg) {
    if (instance != null) {
        instance.toFront();// www. j  a v a2 s  .co  m
        return;
    }
    instance = this;
    addKeyListener(IJ.getInstance());

    if (sourceStackImp == null) {
        sourceStackImp = WindowManager.getCurrentImage();
        if (sourceStackImp != null) {
            centerPixel = 0.5 * (sourceStackImp.getWidth() - 1);
        } else {
            centerPixel = 50; // completely arbitrary
        }
    }

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    Panel valuesPanel = new Panel();
    valuesPanel.setLayout(new GridLayout(6, 2));

    Label centerPixelLabel = new Label("Center Pixel");
    valuesPanel.add(centerPixelLabel);
    centerPixelText = new TextField(IJ.d2s(centerPixel, 1), 15);
    valuesPanel.add(centerPixelText);

    Label detectorAngleLabel = new Label("Detector Angle");
    valuesPanel.add(detectorAngleLabel);
    detectorAngleText = new TextField(IJ.d2s(0, 4), 15);
    valuesPanel.add(detectorAngleText);

    Label horizontalBorderLabel = new Label("Horizontal Border");
    valuesPanel.add(horizontalBorderLabel);
    horizontalBorderText = new TextField("0", 15);
    valuesPanel.add(horizontalBorderText);

    Label topBorderLabel = new Label("Top Border");
    valuesPanel.add(topBorderLabel);
    topBorderText = new TextField("0", 15);
    valuesPanel.add(topBorderText);

    Label bottomBorderLabel = new Label("Bottom Border");
    valuesPanel.add(bottomBorderLabel);
    bottomBorderText = new TextField("0", 15);
    valuesPanel.add(bottomBorderText);

    Label crossCorrelationLabel = new Label("Cross-Correlation");
    valuesPanel.add(crossCorrelationLabel);
    crossCorrelationText = new Label("-");
    valuesPanel.add(crossCorrelationText);

    this.add(valuesPanel);

    updateButton = addButton("Update");
    optimizeButton = addButton("Optimize");
    applyButton = addButton("Apply to stack and save");
    resetButton = addButton("Reset");

    pack();
    GUI.center(this);
    show();
}

From source file:SumUp.java

/** init() is an Applet method called by the browser to initialize */
public void init() {
    setBackground(Color.magenta);
    // The layout of the Applet is a Grid; always add things in pairs!
    setLayout(new GridLayout(0, 2));
    Choice c;/*from   ww  w  .  ja  v a  2 s . co  m*/
    add(new Label("Option 1"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;

    add(new Label("Option 2"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;

    Panel p = new Panel();
    p.setBackground(Color.pink);
    p.add(new Label("Total:"));
    p.add(resultField = new Label("000000"));
    add(p);

    sendButton = new Button("Send it");
    add(sendButton); // connect Button into Applet
    sendButton.addActionListener(this); // connect it back to Applet
}