Example usage for java.lang Integer Integer

List of usage examples for java.lang Integer Integer

Introduction

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

Prototype

@Deprecated(since = "9")
public Integer(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Usage

From source file:MainClass.java

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

    Object iconObject = LookAndFeel.makeIcon(MainClass.class, "yourImage.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.GREEN, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);// w w  w  .  j  a v a  2 s . c om
    frame.setVisible(true);
}

From source file:json.WriteToFile.java

public static void main(String[] args) {
    JSONObject countryObj = new JSONObject();
    countryObj.put("Name", "Kenya");
    countryObj.put("Population", new Integer(430000000));
    JSONArray listOfCounties = new JSONArray();
    listOfCounties.add("Nairobi");
    listOfCounties.add("Kiambu");
    listOfCounties.add("Murang'a");

    countryObj.put("Counties", listOfCounties);
    try {//from   w w  w  .  ja  v a  2  s  .c o  m
        //writing to file
        File file = new File("/home/mars/Desktop/JsonExample1.json");
        file.createNewFile();
        FileWriter fw = new FileWriter(file);
        System.out.println("Writing JSON object to file");
        System.out.println("---------------------------");
        System.out.println(countryObj);

        fw.write(countryObj + "");
        fw.flush();
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.jfree.chart.demo.SecondDemo.java

public static void main(String args[]) {
    XYSeries xyseries = new XYSeries("Advisory Range");
    xyseries.add(new Integer(1200), new Integer(1));
    xyseries.add(new Integer(1500), new Integer(1));
    XYSeries xyseries1 = new XYSeries("Normal Range");
    xyseries1.add(new Integer(2000), new Integer(4));
    xyseries1.add(new Integer(2300), new Integer(4));
    XYSeries xyseries2 = new XYSeries("Recommended");
    xyseries2.add(new Integer(2100), new Integer(2));
    XYSeries xyseries3 = new XYSeries("Current");
    xyseries3.add(new Integer(2400), new Integer(3));
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(xyseries1);
    xyseriescollection.addSeries(xyseries2);
    xyseriescollection.addSeries(xyseries3);
    JFreeChart jfreechart = ChartFactory.createXYLineChart("My Chart", "Calories", "Y", xyseriescollection,
            PlotOrientation.VERTICAL, true, true, false);
    StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(3, null);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setRenderer(standardxyitemrenderer);
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setTickLabelsVisible(false);
    valueaxis.setRange(0.0D, 5D);//ww w.  j a v  a  2s.  c  o  m
    ChartFrame chartframe = new ChartFrame("Test", jfreechart);
    chartframe.pack();
    chartframe.setVisible(true);
}

From source file:Main.java

public static final void main(final String[] args) {
    Integer value = new Integer("123");
    System.out.println("Before: " + value);
    initIntFields(value);/*from   w  w  w . j  a v  a 2s.co m*/
    System.out.println("After: " + value);
}

From source file:EditableTable.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String[] columnTitles = { "First Name", "Last Name", "Weight (lb)", "Blood Group", "Age>20yrs" };
    Object[][] dataEntries = { { "Saravan", "Pantham", new Integer(50), "B", new Boolean(false) },
            { "Eric", "", new Integer(180), "O", new Boolean(true) },
            { "John", "", new Integer(120), "AB", new Boolean(false) },
            { "Mathew", "", new Integer(140), "A", new Boolean(true) }, };
    TableModel model = new EditableTableModel(columnTitles, dataEntries);
    JTable table = new JTable(model);
    table.createDefaultColumnsFromModel();

    String[] bloodGroups = { "A", "B", "AB", "O" };
    JComboBox comboBox = new JComboBox(bloodGroups);
    table.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(comboBox));

    frame.add(new JScrollPane(table));

    frame.setSize(300, 200);//from w  w  w  .  jav  a  2  s.com
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) {
    ArrayList myList = new ArrayList(5);
    for (int i = 0; i < 5; i++) {
        myList.add(new Integer(i));
    }// w w  w.j a  v  a 2  s  .com
    System.out.println("List contains " + myList.size() + " elements");

    Integer int2 = new Integer(2);
    System.out.println("List contains Integer(2): " + myList.contains(int2));
    System.out.println("Integer(2) is at index " + myList.indexOf(int2));

    myList.set(2, new Integer(99));
    System.out.println("Get element at index 2: " + myList.get(2));

    myList.ensureCapacity(15);
    for (int i = 10; i < 15; i++) {
        myList.add(new Integer(i));
    }

    myList.subList(10, 15).clear();
    myList.trimToSize();

    System.out.println(myList);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final Action action = new AbstractAction("Action Name") {
        {//from   ww  w  .j a  v a  2s  .  c o m
            putValue(Action.SHORT_DESCRIPTION, "Tool Tip Text");

            putValue(Action.LONG_DESCRIPTION, "Help Text");

            Icon icon = new ImageIcon("icon.gif");
            putValue(Action.SMALL_ICON, icon);

            putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_A));
            putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control F2"));
        }

        public void actionPerformed(ActionEvent evt) {
            System.out.println("action");
        }
    };

    JButton button = new JButton(action);
}

From source file:LazySample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Lazy Example");

    Object iconObject = LookAndFeel.makeIcon(LazySample.class, "World.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.green, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    Container contentPane = frame.getContentPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);//  ww  w .ja va2 s  .c  om
    frame.setVisible(true);
}

From source file:json.example.JSONExample.java

/**
 * @param args the command line arguments
 * @throws org.json.JSONException//w  w  w.j  a v a2s  .  c  om
 */
public static void main(String[] args) throws JSONException {
    // Require throws JSONException

    // Encode JSONObject subclass HashMap
    JSONObject person = new JSONObject();

    //Fill HashMap with Objects
    person.put("name", "Cassandra");
    person.put("age", new Integer(26));
    person.put("height", new Double(61.25));
    person.put("married", true);

    System.out.print(person);
}

From source file:EditableColumn.java

public static void main(String args[]) {
    TableModel model = new AbstractTableModel() {
        Icon icon1 = new ImageIcon("TreeCollapsed.gif");

        Icon icon2 = new ImageIcon("TreeExpanded.gif");

        Object rowData[][] = { { new Integer(1), "ichi", Boolean.TRUE, new Date("01/01/2000"), icon1 },
                { new Integer(2), "ni", Boolean.TRUE, new Date("04/15/1999"), icon2 },
                { new Integer(3), "san", Boolean.FALSE, new Date("12/07/1941"), icon2 },
                { new Integer(4), "shi", Boolean.TRUE, new Date("02/29/2000"), icon1 },
                { new Integer(5), "go", Boolean.FALSE, new Date("05/23/1995"), icon1 }, };

        String columnNames[] = { "English", "Japanese", "Boolean", "Date", "ImageIcon" };

        public int getColumnCount() {
            return columnNames.length;
        }//w ww  .  ja v  a2  s  . c  o m

        public String getColumnName(int column) {
            return columnNames[column];
        }

        public int getRowCount() {
            return rowData.length;
        }

        public Object getValueAt(int row, int column) {
            return rowData[row][column];
        }

        public Class getColumnClass(int column) {
            return (getValueAt(0, column).getClass());
        }

        public void setValueAt(Object value, int row, int column) {
            rowData[row][column] = value;
        }

        public boolean isCellEditable(int row, int column) {
            return (column != 4);
        }
    };

    JFrame frame = new JFrame("Column Renderer Table");
    JTable table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(400, 150);
    frame.setVisible(true);
}