List of usage examples for java.lang Boolean TRUE
Boolean TRUE
To view the source code for java.lang Boolean TRUE.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { BeanInfo bi = Introspector.getBeanInfo(BeanToXmlTransient.class); PropertyDescriptor[] pds = bi.getPropertyDescriptors(); for (int i = 0; i < pds.length; i++) { PropertyDescriptor propertyDescriptor = pds[i]; if (propertyDescriptor.getName().equals("itemQuantities")) { propertyDescriptor.setValue("transient", Boolean.TRUE); }/*from w w w .ja v a 2 s. c o m*/ } BeanToXmlTransient bean = new BeanToXmlTransient(); bean.setId(new Long(1)); bean.setItemName("Item"); bean.setItemColour("Red"); bean.setItemQuantities(new Integer(100)); XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("BeanTransient.xml"))); encoder.writeObject(bean); encoder.close(); }
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);//from w w w . j av a 2 s .c o m frame.setVisible(true); }
From source file:SimpleAttributeBoldItalic.java
public static void main(String args[]) { JFrame frame = new JFrame("Simple Attributes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); StyledDocument document = new DefaultStyledDocument(); SimpleAttributeSet attributes = new SimpleAttributeSet(); attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE); attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE); try {/*from w ww . j a v a 2 s .c o m*/ document.insertString(document.getLength(), "Bold, Italic", attributes); } catch (BadLocationException badLocationException) { System.err.println("Bad insert"); } JTextPane textPane = new JTextPane(document); textPane.setEditable(false); JScrollPane scrollPane = new JScrollPane(textPane); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.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(); }// w w w . j a va 2s . com } }; 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: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 w w .ja v a 2 s . c om*/ 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); }
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 .jav a2 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" }); 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: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 v a 2 s . com*/ 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:Main.java
public static void main(String[] args) { // Using constructors Boolean b1True = new Boolean(true); Boolean b2True = new Boolean("true"); Boolean b3True = new Boolean("tRuE"); Boolean b4False = new Boolean("false"); Boolean b5False = new Boolean("how is this"); // false // Using the factory methods Boolean b6True = Boolean.valueOf(true); Boolean b7True = Boolean.valueOf("true"); Boolean b8True = Boolean.valueOf("tRuE"); Boolean b9False = Boolean.valueOf("false"); Boolean b10False = Boolean.valueOf("how is this"); // false // Getting a boolean value from a Boolean object boolean bbTrue = b8True.booleanValue(); boolean bTrue = Boolean.parseBoolean("true"); boolean bFalse = Boolean.parseBoolean("This string evaluates to false"); Boolean bcTrue = Boolean.TRUE; Boolean bcFalse = Boolean.FALSE; System.out.println("bcTrue = " + bcTrue); System.out.println("bcFalse = " + bcFalse); }
From source file:SimpleAttributeSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Simple Attributes"); Container content = frame.getContentPane(); StyledDocument document = new DefaultStyledDocument(); SimpleAttributeSet attributes = new SimpleAttributeSet(); attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE); attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE); // Insert content try {//from w w w . j av a 2s. co m document.insertString(document.getLength(), "Hello Java", attributes); } catch (BadLocationException badLocationException) { System.err.println("Oops"); } attributes = new SimpleAttributeSet(); attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.FALSE); attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.FALSE); attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.lightGray); // Insert content try { document.insertString(document.getLength(), " - Good-bye Visual Basic", attributes); } catch (BadLocationException badLocationException) { System.err.println("Oops"); } JTextPane textPane = new JTextPane(document); textPane.setEditable(false); JScrollPane scrollPane = new JScrollPane(textPane); content.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:testRandomTokenIP.java
public static void main(String[] args) { int count = 0; for (int i = 0; i < size; i++) { String ip = RandomStringUtils.random(4, true, true); while (list.containsKey(ip)) { ip = RandomStringUtils.random(4, true, true); }/*ww w . j a va2 s . co m*/ if (list.containsKey(ip)) { count++; System.out.println("Da trung:" + count); } list.put(ip, Boolean.TRUE); } }