Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

In this page you can find the example usage for java.lang Integer toString.

Prototype

@HotSpotIntrinsicCandidate
public static String toString(int i) 

Source Link

Document

Returns a String object representing the specified integer.

Usage

From source file:SizingSamples.java

public static void main(String args[]) {
    String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" };

    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList(labels);
    jlist1.setVisibleRowCount(4);/*from  w w  w .j  a v a2s . c o m*/
    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(100);
    for (int i = 0; i < 100; i++) {
        model.addElement(Integer.toString(i));
    }
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    JList jlist2 = new JList(model);
    jlist2.setVisibleRowCount(4);
    jlist2.setFixedCellHeight(12);
    jlist2.setFixedCellWidth(200);

    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    JList jlist3 = new JList(labels);
    jlist3.setVisibleRowCount(4);
    frame.add(jlist3, BorderLayout.SOUTH);

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:SplitTablePDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);
    try {/*from w w w  .j a v  a 2  s.c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SplitTablePDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        PdfPTable table = new PdfPTable(10);
        for (int i = 1; i <= 100; ++i) {
            table.addCell(Integer.toString(i));
        }
        table.setTotalWidth(800);
        table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
        document.newPage();
        table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:ReadBinaryFile.java

public static void main(String[] args) throws Exception {
    NumberFormat cf = NumberFormat.getCurrencyInstance();

    File file = new File("product.dat");
    DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));

    boolean eof = false;
    while (!eof) {
        Product movie = readMovie(in);//w w w  . jav  a 2s.  c o m
        if (movie == null)
            eof = true;
        else {
            String msg = Integer.toString(movie.year);
            msg += ": " + movie.title;
            msg += " (" + cf.format(movie.price) + ")";
            System.out.println(msg);
        }
    }
    in.close();
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Focus Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ActionListener actionListener = new ActionFocusMover();
    MouseListener mouseListener = new MouseEnterFocusMover();

    frame.setLayout(new GridLayout(3, 3));
    for (int i = 1; i < 10; i++) {
        JButton button = new JButton(Integer.toString(i));
        button.addActionListener(actionListener);
        button.addMouseListener(mouseListener);
        if ((i % 2) != 0) {
            button.setFocusable(false);/*  w  w w .j a va 2 s. co m*/
        }
        frame.add(button);
    }

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:SizingSamples.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(100);//  w  ww  . ja v  a  2s.  co m
    for (int i = 0; i < 100; i++) {
        model.addElement(Integer.toString(i));
    }
    JList jlist2 = new JList(model);
    ListCellRenderer renderer = new FocusedTitleListCellRenderer();
    jlist2.setCellRenderer(renderer);

    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    frame.setSize(300, 350);
    frame.setVisible(true);

    jlist2.ensureIndexIsVisible(50);
}

From source file:ActionFocusMover.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Focus Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ActionListener actionListener = new ActionFocusMover();
    frame.setLayout(new GridLayout(3, 3));
    for (int i = 1; i < 10; i++) {
        JButton button = new JButton(Integer.toString(i));
        button.addActionListener(actionListener);
        if ((i % 2) != 0) {
            button.setFocusable(false);/*from  w ww  .ja v  a  2 s .c  o m*/
        }
        frame.add(button);
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MouseEnterFocusMover.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Focus Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    MouseListener mouseListener = new MouseEnterFocusMover();
    frame.setLayout(new GridLayout(3, 3));
    for (int i = 1; i < 10; i++) {
        JButton button = new JButton(Integer.toString(i));
        button.addMouseListener(mouseListener);
        if ((i % 2) != 0) {
            button.setFocusable(false);//from   w  ww .j ava2  s  .  co m
        }
        frame.add(button);
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:ListMoviesXML.java

public static void main(String[] args) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringComments(true);/*www.j  a va 2  s .c o m*/

    factory.setIgnoringElementContentWhitespace(true);
    factory.setValidating(true);
    DocumentBuilder builder = factory.newDocumentBuilder();

    Document doc = builder.parse(new InputSource("y.xml"));
    Element root = doc.getDocumentElement();

    Element movieElement = (Element) root.getFirstChild();
    Movie m;
    while (movieElement != null) {
        m = getMovie(movieElement);
        String msg = Integer.toString(m.year);
        msg += ": " + m.title;
        msg += " (" + m.price + ")";
        System.out.println(msg);
        movieElement = (Element) movieElement.getNextSibling();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String url = "jdbc:odbc:technical_library";
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String theStatement = "SELECT authid, lastname, firstname, email FROM authors ORDER BY authid";

    try {/*from  w w  w.j ava  2s  .c om*/
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, "guest", "guest");
        Statement queryAuthors = connection.createStatement();
        ResultSet results = queryAuthors.executeQuery(theStatement);

        String lastname, firstname, email;
        int id;
        while (results.next()) {
            id = results.getInt(1);
            lastname = results.getString(2);
            firstname = results.getString(3);
            email = results.getString(4);

            if (results.wasNull()) {
                email = "no email";
            }
            System.out.println(Integer.toString(id) + ", " + lastname.trim() + ", " + firstname.trim() + ", "
                    + email.trim());
        }
        queryAuthors.close();
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = docBuilderFactory.newDocumentBuilder();
    Document node = documentBuilder.parse(new FileInputStream("data.xml"));
    cleanEmptyTextNodes(node);//from   w  ww . jav  a 2s  .c om
    StreamResult result = new StreamResult(new StringWriter());

    Transformer transformer = TransformerFactory.newInstance().newTransformer();

    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(4));

    transformer.transform(new DOMSource(node), result);
    System.out.println(result.getWriter().toString());
}