Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:jsonencodedemo.JsonEncodeDemo.java

public static void main(String[] args) {
    JSONObject obj = new JSONObject();

    obj.put("name", "Jordan");
    obj.put("school", "BYUI");
    obj.put("age", new Integer(31));
    obj.put("year", new Integer(2015));
    obj.put("is_student", new Boolean(true));

    System.out.print(obj);/* www  .  j ava 2 s .c o m*/
}

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 .j a  v  a  2s  . co  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel gui = new JPanel(new BorderLayout(2, 3));

    JPanel buttonConstrsint = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton getQuotesButton = new JButton("Load");
    buttonConstrsint.add(getQuotesButton);
    gui.add(buttonConstrsint, BorderLayout.NORTH);

    getQuotesButton.addActionListener(e -> {
        String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

        Object[][] data = { { "A", "B", "Snowboarding", new Integer(5), new Boolean(false) },
                { "C", "D", "Pool", new Integer(10), new Boolean(false) } };

        JTable table = new JTable(data, columnNames);

        JScrollPane scrollPane = new JScrollPane(table);
        table.setFillsViewportHeight(true);

        gui.add(scrollPane, BorderLayout.CENTER);
        gui.revalidate();//from   w  w w.ja va  2  s  .c  o m
        gui.repaint();
    });

    JOptionPane jOptionPane = new JOptionPane(gui);

    JDialog dialog = jOptionPane.createDialog(new JFrame(), "title");
    dialog.setSize(200, 200);
    dialog.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    StyleContext sc = new StyleContext();
    final DefaultStyledDocument doc = new DefaultStyledDocument(sc);
    JTextPane pane = new JTextPane(doc);

    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 {//from  w  ww  .j a v  a 2 s  .  c  o m
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                try {
                    doc.insertString(0, text, null);

                    doc.setParagraphAttributes(0, 1, heading2Style, false);
                } 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:StylesExample5.java

public static void main(String[] args) {
    try {//from   w ww.  jav a2  s . 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:fuse.okuyamafs.OkuyamaFuse.java

public static void main(String[] args) {

    String fuseArgs[] = new String[args.length - 1];
    System.arraycopy(args, 0, fuseArgs, 0, fuseArgs.length);

    ImdstDefine.valueCompresserLevel = 9;
    try {/*ww w .  j av a2 s  .c o  m*/
        String okuyamaStr = args[args.length - 1];

        // Raid0?????????
        if (okuyamaStr.indexOf("#") != -1) {
            stripingDataBlock = true;
            okuyamaStr = okuyamaStr.substring(0, (okuyamaStr.length() - 1));
        }

        String[] masterNodeInfos = null;
        if (okuyamaStr.indexOf(",") != -1) {
            masterNodeInfos = okuyamaStr.split(",");
        } else {
            masterNodeInfos = (okuyamaStr + "," + okuyamaStr).split(",");
        }
        // 1=Memory
        // 2=okuyama
        // 3=LocalCacheOkuyama

        String[] optionParams = { "2", "true" };
        String fsystemMode = optionParams[0].trim();
        boolean singleFlg = new Boolean(optionParams[1].trim()).booleanValue();

        OkuyamaFilesystem.storageType = new Integer(fsystemMode).intValue();
        if (OkuyamaFilesystem.storageType == 1)
            OkuyamaFilesystem.blockSize = OkuyamaFilesystem.blockSize;

        CoreMapFactory.init(new Integer(fsystemMode.trim()).intValue(), masterNodeInfos, stripingDataBlock);
        FilesystemCheckDaemon loopDaemon = new FilesystemCheckDaemon(1, fuseArgs[fuseArgs.length - 1]);
        loopDaemon.start();

        if (OkuyamaFilesystem.storageType == 2) {
            FilesystemCheckDaemon bufferCheckDaemon = new FilesystemCheckDaemon(2, null);
            bufferCheckDaemon.start();
        }

        Runtime.getRuntime().addShutdownHook(new JVMShutdownSequence());
        FuseMount.mount(fuseArgs, new OkuyamaFilesystem(fsystemMode, singleFlg), log);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ReplaceReader.java

public static void main(String[] args) {
    try {//from   w w  w. j a va  2s  . c  o m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new JFrame("JEditorPane with Custom Reader");
    JEditorPane ep = new JEditorPane();
    f.getContentPane().add(new JScrollPane(ep));
    f.setSize(400, 300);
    f.setVisible(true);

    HTMLEditorKit kit = new HTMLEditorKit() {
        public Document createDefaultDocument() {
            HTMLDocument doc = new CustomHTMLDocument(getStyleSheet());
            doc.setAsynchronousLoadPriority(4);
            doc.setTokenThreshold(100);
            return doc;
        }
    };
    ep.setEditorKit(kit);

    try {
        Document doc = ep.getDocument();
        doc.putProperty("IgnoreCharsetDirective", new Boolean(true));
        kit.read(new FileReader(args[0]), doc, 0);
    } catch (Exception e) {
        System.out.println("Exception while reading HTML " + e);
    }
}

From source file:SortBooleans.java

public static void main(String[] unused) {
    Boolean[] data = { new Boolean(true), new Boolean(false), new Boolean(false), new Boolean(true), };
    Arrays.sort(data); // EXPECT RUNTIME ERROR
    for (int i = 0; i < data.length; i++)
        System.out.println(data[i]);
}

From source file:de.dominicscheurer.passwords.Main.java

/**
 * @param args//from ww  w.j  a va2  s .  c  om
 *            Command line arguments (see code or output of program when
 *            started with no arguments).
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();

    Option seedPwdOpt = OptionBuilder.withArgName("Seed Password").isRequired().hasArg()
            .withDescription("Password used as a seed").withLongOpt("seed-password").create("s");

    Option serviceIdOpt = OptionBuilder.withArgName("Service Identifier").isRequired().hasArg()
            .withDescription("The service that the password is created for, e.g. facebook.com")
            .withLongOpt("service-identifier").create("i");

    Option pwdLengthOpt = OptionBuilder.withArgName("Password Length").withType(Integer.class).hasArg()
            .withDescription("Length of the password in characters").withLongOpt("pwd-length").create("l");

    Option specialChars = OptionBuilder.withArgName("With special chars (TRUE|false)").withType(Boolean.class)
            .hasArg().withDescription("Set to true if special chars !-_?=@/+* are desired, else false")
            .withLongOpt("special-chars").create("c");

    Option suppressPwdOutpOpt = OptionBuilder
            .withDescription("Suppress password output (copy to clipboard only)").withLongOpt("hide-password")
            .hasArg(false).create("x");

    Option helpOpt = OptionBuilder.withDescription("Prints this help message").withLongOpt("help").create("h");

    options.addOption(seedPwdOpt);
    options.addOption(serviceIdOpt);
    options.addOption(pwdLengthOpt);
    options.addOption(specialChars);
    options.addOption(suppressPwdOutpOpt);
    options.addOption(helpOpt);

    CommandLineParser parser = new GnuParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("h")) {
            SafePwdGen.printHelp(options);
            System.exit(0);
        }

        int pwdLength = STD_PWD_LENGTH;
        if (cmd.hasOption("l")) {
            pwdLength = new Integer(cmd.getOptionValue("l"));
        }

        boolean useSpecialChars = true;
        if (cmd.hasOption("c")) {
            useSpecialChars = new Boolean(cmd.getOptionValue("c"));
        }

        if (pwdLength > MAX_PWD_LENGTH_64 && !useSpecialChars) {
            System.out.println(PASSWORD_SIZE_TOO_BIG + MAX_PWD_LENGTH_64);
        }

        if (pwdLength > MAX_PWD_LENGTH_71 && useSpecialChars) {
            System.out.println(PASSWORD_SIZE_TOO_BIG + MAX_PWD_LENGTH_71);
        }

        boolean suppressPwdOutput = cmd.hasOption('x');

        String pwd = SafePwdGen.createPwd(cmd.getOptionValue("s"), cmd.getOptionValue("i"), pwdLength,
                useSpecialChars);

        if (!suppressPwdOutput) {
            System.out.print(GENERATED_PASSWORD);
            System.out.println(pwd);
        }
        System.out.println(CLIPBOARD_COPIED_MSG);
        SystemClipboardInterface.copy(pwd);

        System.in.read();
    } catch (ParseException e) {
        System.out.println(e.getLocalizedMessage());
        SafePwdGen.printHelp(options);
    } catch (UnsupportedEncodingException e) {
        System.out.println(e.getLocalizedMessage());
    } catch (NoSuchAlgorithmException e) {
        System.out.println(e.getLocalizedMessage());
    } catch (IOException e) {
        System.out.println(e.getLocalizedMessage());
    }
}

From source file:examples.TelnetClientExample.java

/***
 * Main for the TelnetClientExample./*ww  w.ja  v  a2 s . co  m*/
 ***/
public static void main(String[] args) throws IOException {
    FileOutputStream fout = null;

    if (args.length < 1) {
        System.err.println("Usage: TelnetClientExample1 <remote-ip> [<remote-port>]");
        System.exit(1);
    }

    String remoteip = args[0];

    int remoteport;

    if (args.length > 1) {
        remoteport = (new Integer(args[1])).intValue();
    } else {
        remoteport = 23;
    }

    try {
        fout = new FileOutputStream("spy.log", true);
    } catch (Exception e) {
        System.err.println("Exception while opening the spy file: " + e.getMessage());
    }

    tc = new TelnetClient();

    TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
    EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
    SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);

    try {
        tc.addOptionHandler(ttopt);
        tc.addOptionHandler(echoopt);
        tc.addOptionHandler(gaopt);
    } catch (InvalidTelnetOptionException e) {
        System.err.println("Error registering option handlers: " + e.getMessage());
    }

    while (true) {
        boolean end_loop = false;
        try {
            tc.connect(remoteip, remoteport);

            Thread reader = new Thread(new TelnetClientExample());
            tc.registerNotifHandler(new TelnetClientExample());
            System.out.println("TelnetClientExample");
            System.out.println("Type AYT to send an AYT telnet command");
            System.out.println("Type OPT to print a report of status of options (0-24)");
            System.out.println("Type REGISTER to register a new SimpleOptionHandler");
            System.out.println("Type UNREGISTER to unregister an OptionHandler");
            System.out.println("Type SPY to register the spy (connect to port 3333 to spy)");
            System.out.println("Type UNSPY to stop spying the connection");

            reader.start();
            OutputStream outstr = tc.getOutputStream();

            byte[] buff = new byte[1024];
            int ret_read = 0;

            do {
                try {
                    ret_read = System.in.read(buff);
                    if (ret_read > 0) {
                        if ((new String(buff, 0, ret_read)).startsWith("AYT")) {
                            try {
                                System.out.println("Sending AYT");

                                System.out.println("AYT response:" + tc.sendAYT(5000));
                            } catch (Exception e) {
                                System.err.println("Exception waiting AYT response: " + e.getMessage());
                            }
                        } else if ((new String(buff, 0, ret_read)).startsWith("OPT")) {
                            System.out.println("Status of options:");
                            for (int ii = 0; ii < 25; ii++)
                                System.out.println("Local Option " + ii + ":" + tc.getLocalOptionState(ii)
                                        + " Remote Option " + ii + ":" + tc.getRemoteOptionState(ii));
                        } else if ((new String(buff, 0, ret_read)).startsWith("REGISTER")) {
                            StringTokenizer st = new StringTokenizer(new String(buff));
                            try {
                                st.nextToken();
                                int opcode = (new Integer(st.nextToken())).intValue();
                                boolean initlocal = (new Boolean(st.nextToken())).booleanValue();
                                boolean initremote = (new Boolean(st.nextToken())).booleanValue();
                                boolean acceptlocal = (new Boolean(st.nextToken())).booleanValue();
                                boolean acceptremote = (new Boolean(st.nextToken())).booleanValue();
                                SimpleOptionHandler opthand = new SimpleOptionHandler(opcode, initlocal,
                                        initremote, acceptlocal, acceptremote);
                                tc.addOptionHandler(opthand);
                            } catch (Exception e) {
                                if (e instanceof InvalidTelnetOptionException) {
                                    System.err.println("Error registering option: " + e.getMessage());
                                } else {
                                    System.err.println("Invalid REGISTER command.");
                                    System.err.println(
                                            "Use REGISTER optcode initlocal initremote acceptlocal acceptremote");
                                    System.err.println("(optcode is an integer.)");
                                    System.err.println(
                                            "(initlocal, initremote, acceptlocal, acceptremote are boolean)");
                                }
                            }
                        } else if ((new String(buff, 0, ret_read)).startsWith("UNREGISTER")) {
                            StringTokenizer st = new StringTokenizer(new String(buff));
                            try {
                                st.nextToken();
                                int opcode = (new Integer(st.nextToken())).intValue();
                                tc.deleteOptionHandler(opcode);
                            } catch (Exception e) {
                                if (e instanceof InvalidTelnetOptionException) {
                                    System.err.println("Error unregistering option: " + e.getMessage());
                                } else {
                                    System.err.println("Invalid UNREGISTER command.");
                                    System.err.println("Use UNREGISTER optcode");
                                    System.err.println("(optcode is an integer)");
                                }
                            }
                        } else if ((new String(buff, 0, ret_read)).startsWith("SPY")) {
                            try {
                                tc.registerSpyStream(fout);
                            } catch (Exception e) {
                                System.err.println("Error registering the spy");
                            }
                        } else if ((new String(buff, 0, ret_read)).startsWith("UNSPY")) {
                            tc.stopSpyStream();
                        } else {
                            try {
                                outstr.write(buff, 0, ret_read);
                                outstr.flush();
                            } catch (Exception e) {
                                end_loop = true;
                            }
                        }
                    }
                } catch (Exception e) {
                    System.err.println("Exception while reading keyboard:" + e.getMessage());
                    end_loop = true;
                }
            } while ((ret_read > 0) && (end_loop == false));

            try {
                tc.disconnect();
            } catch (Exception e) {
                System.err.println("Exception while connecting:" + e.getMessage());
            }
        } catch (Exception e) {
            System.err.println("Exception while connecting:" + e.getMessage());
            System.exit(1);
        }
    }
}