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:Main.java

/**
 * Sets the index of the Node instance's "current" child as user data on
 * the Node instance./*from   w  w w . ja  v  a 2 s  .c  o m*/
 * 
 * @param node Node instance on which to set index.
 * @param index Index of node's "current" child.
 * @return true if index has changed, else false.
 */
public static boolean setCurrentChildIndex(Node node, int index) {
    boolean indexChanged = false;
    if (node != null) {
        int currentIndex = getCurrentChildIndex(node);
        if (currentIndex != index) {
            node.setUserData(KEY_CURRENT_CHILD_INDEX, new Integer(index), null);
            indexChanged = true;
        }
    }
    return indexChanged;
}

From source file:MyComparator.java

public int compare(String a, String b) {
    return new Integer(a.length()).compareTo(b.length());
}

From source file:Main.java

public static List<Integer> toList(int... array) {
    if (isEmpty(array)) {
        return new ArrayList<>(0);
    }//from  w w  w  . j  a va 2  s.co m
    List<Integer> list = new ArrayList<>(array.length);
    for (int I : array) {
        list.add(new Integer(I));
    }
    return list;
}

From source file:WordCount.java

static void addWord(Map map, String word) {
    Object obj = map.get(word);/*from w ww .j ava  2 s.c  om*/
    if (obj == null) {
        map.put(word, ONE);
    } else {
        int i = ((Integer) obj).intValue() + 1;
        map.put(word, new Integer(i));
    }
}

From source file:CountFilesAction.java

public Object run() {
    File f = new File(File.separatorChar + "files");
    File[] fArray = f.listFiles();
    return new Integer(fArray.length);
}

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

private static XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Random 1");
    xyseries.add(new Integer(1), new Double(500.19999999999999D));
    xyseries.add(new Integer(2), new Double(694.10000000000002D));
    xyseries.add(new Integer(3), new Double(-734.39999999999998D));
    xyseries.add(new Integer(4), new Double(453.19999999999999D));
    xyseries.add(new Integer(5), new Double(500.19999999999999D));
    xyseries.add(new Integer(6), new Double(300.69999999999999D));
    xyseries.add(new Integer(7), new Double(734.39999999999998D));
    xyseries.add(new Integer(8), new Double(453.19999999999999D));
    XYSeries xyseries1 = new XYSeries("Random 2");
    xyseries1.add(new Integer(1), new Double(700.20000000000005D));
    xyseries1.add(new Integer(2), new Double(534.10000000000002D));
    xyseries1.add(new Integer(3), new Double(323.39999999999998D));
    xyseries1.add(new Integer(4), new Double(125.2D));
    xyseries1.add(new Integer(5), new Double(653.20000000000005D));
    xyseries1.add(new Integer(6), new Double(432.69999999999999D));
    xyseries1.add(new Integer(7), new Double(564.39999999999998D));
    xyseries1.add(new Integer(8), new Double(322.19999999999999D));
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(xyseries1);
    xyseriescollection.setIntervalWidth(0.0D);
    return xyseriescollection;
}

From source file:ShowAction.java

public ShowAction() {
    super("About");
    putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
}

From source file:Main.java

/**
 *
 * @param parent Element//from   w  w  w.  j  a v  a2s  .co  m
 * @param name String
 * @param value int
 */
public static void appendAttributeNode(Element parent, String name, int value) {
    parent.setAttribute(name, new Integer(value).toString());
}

From source file:JSliderOnJOptionPane.java

static JSlider getSlider(final JOptionPane optionPane) {
    JSlider slider = new JSlider();
    slider.setMajorTickSpacing(10);//from   ww  w  . j a  v  a2  s .  co m
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JSlider theSlider = (JSlider) changeEvent.getSource();
            if (!theSlider.getValueIsAdjusting()) {
                optionPane.setInputValue(new Integer(theSlider.getValue()));
            }
        }
    };
    slider.addChangeListener(changeListener);
    return slider;
}

From source file:Main.java

Main() {
    Object[][] data = { { "A", "B", "Snowboarding", new Integer(5) }, { "C", "D", "Pool", new Integer(10) } };
    Object[] columnNames = { "firstname", "lastname", "age" };
    final JTable table = new JTable(data, columnNames) {
        @Override//from  ww  w . j ava 2  s  .  c  o  m
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            int n = getRowHeight();
            return new Dimension(d.width, (n * ROWS));
        }
    };
    JPanel jPanel = new JPanel();
    jPanel.setLayout(new GridLayout());
    JScrollPane sp = new JScrollPane(table);
    jPanel.add(sp);
    JDialog jdialog = new JDialog();
    jdialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    jdialog.setContentPane(jPanel);

    jdialog.pack();
    jdialog.setVisible(true);
}