Example usage for java.lang String valueOf

List of usage examples for java.lang String valueOf

Introduction

In this page you can find the example usage for java.lang String valueOf.

Prototype

public static String valueOf(double d) 

Source Link

Document

Returns the string representation of the double argument.

Usage

From source file:Main.java

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

    JFrame frame = new JFrame("Testing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(label);//from  w w  w. jav  a 2 s . com

    JPanel buttons = new JPanel(new GridLayout(0, 1));
    for (int index = 0; index < 10; index++) {
        buttons.add(new JButton(String.valueOf(index)));
    }

    JPanel right = new JPanel(new BorderLayout());
    right.add(buttons, BorderLayout.NORTH);
    frame.add(right, BorderLayout.EAST);

    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from w w  w  .j  a  v a  2  s .  c  om*/
    Chunk c = new Chunk("this is a test");
    float w = c.getWidthPoint();
    Paragraph p = new Paragraph("The width of the chunk: '");
    p.add(c);
    p.add("' is ");

    p.add(String.valueOf(w));
    p.add(" points or ");
    p.add(String.valueOf(w / 72f));
    p.add(" inches or ");
    p.add(String.valueOf(w / 72f * 2.54f));
    p.add(" cm.");
    document.add(p);
    document.add(c);
    c.setHorizontalScaling(0.5f);
    document.add(c);
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));

    document.open();/*from w w w.  j  ava 2s  . c  o m*/

    String text = (char) 945 + " " + (char) 946 + " " + (char) 947;
    document.add(Phrase.getInstance(text));
    document.add(Chunk.NEWLINE);
    for (int i = 913; i < 970; i++) {
        document.add(Phrase.getInstance(String.valueOf(i) + ": " + (char) i + " "));
    }
    document.close();
}

From source file:Main.java

public static void main(String argv[]) {
    Main pane = new Main();
    for (int n = 1; n <= 4; n += 1) {
        pane.appendNaive(Color.black, String.valueOf(n) + ' ');
    }/*from   ww  w  .j a  v a2s .com*/
    JFrame f = new JFrame("ColorPane example");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new JScrollPane(pane));
    f.setSize(600, 400);
    f.setVisible(true);
}

From source file:ChunkWidthPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/* w w w.j  a  v a 2  s .c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("ChunkWidthPDF.pdf"));
        document.open();

        Chunk c = new Chunk("Text Text Text Text Text Text Text Text Text Text");
        float w = c.getWidthPoint();
        System.out.println(
                "The width of the chunk: is " + String.valueOf(w) + " points or " + w / 72f + " inches.");
        document.add(c);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(final String[] args) {
    ConcurrentHashMap<Integer, UUID> concurrentHashMap = new ConcurrentHashMap<>();

    for (int i = 0; i < 100; i++) {
        concurrentHashMap.put(i, UUID.randomUUID());
    }/*  w w  w . jav  a2 s. c om*/

    int threshold = 1;

    concurrentHashMap.forEachValue(threshold, System.out::println);

    concurrentHashMap.forEach((id, uuid) -> {
        if (id % 10 == 0) {
            System.out.println(String.format("%s: %s", id, uuid));
        }
    });

    String searchResult = concurrentHashMap.search(threshold, (id, uuid) -> {
        if (String.valueOf(uuid).contains(String.valueOf(id))) {
            return new String(id + ":" + uuid);
        }
        return null;
    });

    System.out.println(searchResult);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document(PageSize.A4);
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from  w  w  w. j  av a2 s. c  o  m*/
    MultiColumnText mct = new MultiColumnText();
    mct.addRegularColumns(document.left(), document.right(), 10f, 3);
    for (int i = 0; i < 30; i++) {
        mct.addElement(new Paragraph(String.valueOf(i + 1)));
        mct.addElement(newParagraph("noun", Element.ALIGN_CENTER, Font.BOLDITALIC));
        for (int j = 0; j < 4; j++) {
            mct.addElement(newParagraph("Line", Element.ALIGN_LEFT, Font.NORMAL));
        }
        mct.addElement(newParagraph("adverb", Element.ALIGN_LEFT, Font.NORMAL));
        mct.addElement(newParagraph("\n\n", Element.ALIGN_LEFT, Font.NORMAL));
    }
    document.add(mct);
    document.close();
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document(PageSize.A4);
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));

    document.open();//from   w  w  w  . j  a  v  a 2  s.c o m

    MultiColumnText mct = new MultiColumnText();
    mct.addSimpleColumn(100, 280);
    mct.addSimpleColumn(300, 480);

    for (int i = 0; i < 30; i++) {
        mct.addElement(new Paragraph(String.valueOf(i + 1)));
        mct.addElement(newParagraph("noun", Element.ALIGN_CENTER, Font.BOLDITALIC));
        for (int j = 0; j < 4; j++) {
            mct.addElement(newParagraph("Line", Element.ALIGN_LEFT, Font.NORMAL));
        }
        mct.addElement(newParagraph("adverb", Element.ALIGN_LEFT, Font.NORMAL));
        mct.addElement(newParagraph("\n\n", Element.ALIGN_LEFT, Font.NORMAL));
    }
    document.add(mct);
    document.close();
    document.close();
}

From source file:Main.java

public static void main(String argv[]) {
    Main pane = new Main();
    for (int n = 1; n <= 4; n += 1) {
        pane.append(Color.black, String.valueOf(n) + ' ');
    }/*from www.j  a  va2s . c  o m*/
    JFrame f = new JFrame("ColorPane example");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new JScrollPane(pane));
    f.setSize(600, 400);
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document(PageSize.A4);
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from   w w w .j a v a 2 s  .  com*/
    MultiColumnText mct = new MultiColumnText();
    mct.setColumnsRightToLeft(true);
    mct.addRegularColumns(document.left(), document.right(), 10f, 3);
    for (int i = 0; i < 30; i++) {
        mct.addElement(new Paragraph(String.valueOf(i + 1)));
        mct.addElement(newParagraph("noun", Element.ALIGN_CENTER, Font.BOLDITALIC));
        for (int j = 0; j < 4; j++) {
            mct.addElement(newParagraph("Line", Element.ALIGN_LEFT, Font.NORMAL));
        }
        mct.addElement(newParagraph("adverb", Element.ALIGN_LEFT, Font.NORMAL));
        mct.addElement(newParagraph("\n\n", Element.ALIGN_LEFT, Font.NORMAL));
    }
    document.add(mct);
    document.close();
    document.close();
}