List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);//from www.ja va2 s . c o m s.setText("A Slider Example"); final Slider slide = new Slider(s, SWT.HORIZONTAL); slide.setBounds(15, 50, 125, 15); slide.setMinimum(0); slide.setMaximum(100); slide.setIncrement(1); final Text t = new Text(s, SWT.BORDER); t.setBounds(115, 25, 25, 25); t.setText("0"); slide.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { t.setText(new Integer(slide.getSelection()).toString()); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:StylesExample5.java
public static void main(String[] args) { try {/*from ww w . j a v a2s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Styles Example 5"); // Create the StyleContext, the document and the pane StyleContext sc = new StyleContext(); final DefaultStyledDocument doc = new DefaultStyledDocument(sc); final JTextPane pane = new JTextPane(doc); // Create and add the style final Style heading2Style = sc.addStyle("Heading2", null); heading2Style.addAttribute(StyleConstants.Foreground, Color.red); heading2Style.addAttribute(StyleConstants.FontSize, new Integer(16)); heading2Style.addAttribute(StyleConstants.FontFamily, "serif"); heading2Style.addAttribute(StyleConstants.Bold, new Boolean(true)); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { // Add the text to the document doc.insertString(0, text, null); // Finally, apply the style to the heading doc.setParagraphAttributes(0, 1, heading2Style, false); // Set the foreground and font pane.setForeground(Color.blue); pane.setFont(new Font("serif", Font.PLAIN, 12)); } catch (BadLocationException e) { } } }); } catch (Exception e) { System.out.println("Exception when constructing document: " + e); System.exit(1); } f.getContentPane().add(new JScrollPane(pane)); f.setSize(400, 300); f.setVisible(true); }
From source file:SampleSet.java
public static void main(String[] args) { Rectangle r = new Rectangle(100, 20); System.out.println("original: " + r.toString()); modifyWidth(r, new Integer(300)); System.out.println("modified: " + r.toString()); }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int columnIndex) { Object o = getValueAt(0, columnIndex); if (o == null) { return Object.class; } else { return o.getClass(); }// www . j a va 2 s. c o m } }; JTable table = new JTable(model); model.addColumn("Boolean", new Object[] { Boolean.TRUE }); model.addColumn("Date", new Object[] { new Date() }); model.addColumn("Double", new Object[] { new Double(Math.PI) }); model.addColumn("Float", new Object[] { new Float(1.2) }); model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") }); model.addColumn("Number", new Object[] { new Integer(1) }); model.addColumn("Object", new Object[] { "object" }); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int columnIndex) { Object o = getValueAt(0, columnIndex); if (o == null) { return Object.class; } else { return o.getClass(); }/*from w w w .ja va 2 s. co m*/ } }; JTable table = new JTable(model); model.addColumn("Boolean", new Object[] { Boolean.TRUE }); model.addColumn("Date", new Object[] { new Date() }); model.addColumn("Double", new Object[] { new Double(Math.PI) }); model.addColumn("Float", new Object[] { new Float(1.2) }); model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") }); model.addColumn("Number", new Object[] { new Integer(1) }); model.addColumn("Object", new Object[] { "object" }); Enumeration e = table.getColumnModel().getColumns(); TableColumn col = (TableColumn) e.nextElement(); col.setCellRenderer(table.getDefaultRenderer(Boolean.class)); col.setCellEditor(table.getDefaultEditor(Boolean.class)); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:ResourceModExample.java
public static void main(String[] args) { Border border = BorderFactory.createRaisedBevelBorder(); Border tripleBorder = new CompoundBorder(new CompoundBorder(border, border), border); UIManager.put("Button.border", tripleBorder); UIManager.put("InternalFrame.closeIcon", new ImageIcon("close.gif")); UIManager.put("InternalFrame.iconizeIcon", new ImageIcon("iconify.gif")); UIManager.put("InternalFrame.maximizeIcon", new ImageIcon("maximize.gif")); UIManager.put("InternalFrame.altMaximizeIcon", new ImageIcon("altMax.gif")); UIManager.put("InternalFrame.titleFont", new Font("Serif", Font.ITALIC, 12)); UIManager.put("ScrollBar.width", new Integer(30)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); JDesktopPane desk = new JDesktopPane(); c.add(desk, BorderLayout.CENTER); JButton cut = new JButton("Cut"); JButton copy = new JButton("Copy"); JButton paste = new JButton("Paste"); JPanel p = new JPanel(new FlowLayout()); p.add(cut);/* ww w . j a v a 2s .co m*/ p.add(copy); p.add(paste); c.add(p, BorderLayout.SOUTH); JInternalFrame inf = new JInternalFrame("MyFrame", true, true, true, true); JLabel l = new JLabel(new ImageIcon("luggage.jpeg")); JScrollPane scroll = new JScrollPane(l); inf.setContentPane(scroll); inf.setBounds(10, 10, 350, 280); desk.add(inf); inf.setVisible(true); f.setSize(380, 360); f.setVisible(true); }
From source file:SampleSliders.java
public static void main(String args[]) { String title = (args.length == 0 ? "Sample Slider" : args[0]); JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider js1 = new JSlider(); js1.putClientProperty("JSlider.isFilled", Boolean.TRUE); JSlider js2 = new JSlider(); js2.setMajorTickSpacing(25);/*from w w w. j a va 2 s . co m*/ js2.setPaintTicks(true); js2.setSnapToTicks(true); JSlider js3 = new JSlider(JSlider.VERTICAL); js3.setPaintTrack(false); js3.setMinorTickSpacing(5); js3.setMajorTickSpacing(10); js3.setPaintTicks(true); js3.setPaintLabels(true); js3.setSnapToTicks(true); JSlider js4 = new JSlider(JSlider.VERTICAL); Hashtable table = new Hashtable(); table.put(new Integer(0), new JLabel(new DiamondIcon(Color.red))); table.put(new Integer(10), new JLabel("Ten")); table.put(new Integer(25), new JLabel("Twenty-Five")); table.put(new Integer(34), new JLabel("Thirty-Four")); table.put(new Integer(52), new JLabel("Fifty-Two")); table.put(new Integer(70), new JLabel("Seventy")); table.put(new Integer(82), new JLabel("Eighty-Two")); table.put(new Integer(100), new JLabel(new DiamondIcon(Color.black))); js4.setLabelTable(table); js4.setPaintLabels(true); js4.setSnapToTicks(true); Container c = f.getContentPane(); c.add(js1, BorderLayout.NORTH); c.add(js2, BorderLayout.SOUTH); c.add(js3, BorderLayout.WEST); c.add(js4, BorderLayout.EAST); f.setSize(300, 200); f.setVisible(true); }
From source file:WordCount.java
public static void main(String args[]) throws Exception { String filename = "WordCount.java"; // Map File from filename to byte buffer FileInputStream input = new FileInputStream(filename); FileChannel channel = input.getChannel(); int fileLength = (int) channel.size(); MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, fileLength); // Convert to character buffer Charset charset = Charset.forName("ISO-8859-1"); CharsetDecoder decoder = charset.newDecoder(); CharBuffer charBuffer = decoder.decode(buffer); // Create line pattern Pattern linePattern = Pattern.compile(".*$", Pattern.MULTILINE); // Create word pattern Pattern wordBreakPattern = Pattern.compile("[\\p{Punct}\\s}]"); // Match line pattern to buffer Matcher lineMatcher = linePattern.matcher(charBuffer); Map map = new TreeMap(); Integer ONE = new Integer(1); // For each line while (lineMatcher.find()) { // Get line CharSequence line = lineMatcher.group(); // Get array of words on line String words[] = wordBreakPattern.split(line); // For each word for (int i = 0, n = words.length; i < n; i++) { if (words[i].length() > 0) { Integer frequency = (Integer) map.get(words[i]); if (frequency == null) { frequency = ONE;/*from w ww.j av a 2s . c o m*/ } else { int value = frequency.intValue(); frequency = new Integer(value + 1); } map.put(words[i], frequency); } } } System.out.println(map); }
From source file:com.discursive.jccook.xml.bardsearch.TermFreq.java
public static void main(String[] pArgs) throws Exception { logger.info("Threshold is 200"); Integer threshold = new Integer(200); IndexReader reader = IndexReader.open("index"); TermEnum enumVar = reader.terms();//from w w w .jav a2 s. c om List termList = new ArrayList(); while (enumVar.next()) { if (enumVar.docFreq() >= threshold.intValue() && enumVar.term().field().equals("speech")) { Freq freq = new Freq(enumVar.term().text(), enumVar.docFreq()); termList.add(freq); } } Collections.sort(termList); Collections.reverse(termList); System.out.println("Frequency | Term"); Iterator iterator = termList.iterator(); while (iterator.hasNext()) { Freq freq = (Freq) iterator.next(); System.out.print(freq.frequency); System.out.println(" | " + freq.term); } }
From source file:org.seasar.dao.spring.example.EmployeeAutoDaoClient.java
public static void main(final String[] args) { final BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(); final BeanFactoryReference ref = locator.useBeanFactory("context"); final ApplicationContext context = (ApplicationContext) ref.getFactory(); try {//from w w w. j a va2 s . com final EmployeeAutoDao dao = (EmployeeAutoDao) context.getBean("employeeAutoDao"); dao.getEmployeeByJobDeptno(null, null); dao.getEmployeeByJobDeptno("CLERK", null); dao.getEmployeeByJobDeptno(null, new Integer(20)); dao.getEmployeeByJobDeptno("CLERK", new Integer(20)); List employees = dao.getEmployeesBySal(0, 1000); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } employees = dao.getEmployeeByDname("SALES"); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final EmployeeSearchCondition dto = new EmployeeSearchCondition(); dto.setDname("RESEARCH"); employees = dao.getEmployeesBySearchCondition(dto); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final Employee employee = dao.getEmployeeByEmpno(7788); System.out.println("before timestamp:" + employee.getTimestamp()); dao.update(employee); System.out.println("after timestamp:" + employee.getTimestamp()); } finally { ref.release(); } }