Example usage for javax.swing JTextArea setLineWrap

List of usage examples for javax.swing JTextArea setLineWrap

Introduction

In this page you can find the example usage for javax.swing JTextArea setLineWrap.

Prototype

@BeanProperty(preferred = true, description = "should lines be wrapped")
public void setLineWrap(boolean wrap) 

Source Link

Document

Sets the line-wrapping policy of the text area.

Usage

From source file:UI.SecurityDashboard.java

private void performMetric4(MainViewPanel mvp) {
    Metric4 metric4 = new Metric4();

    JPanel graphPanel4 = new JPanel();
    graphPanel4.setLayout(new BorderLayout());
    metric4.run();//  w  ww .  j  ava2  s. c  om
    graphPanel4.add(mvp.getPanel4(metric4), BorderLayout.CENTER);

    MalwarePanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nThe Malware detection will scan for viruses, trojans, and worms that may have affected a device.\n");
    header.setLineWrap(true);
    header.setWrapStyleWord(true);
    header.setEditable(false);
    MalwarePanel.add(header, BorderLayout.NORTH);
    if (metric4.getTotalCount() == 0) {
        Font noMalwareFont = new Font("Calibri", Font.BOLD, 40);
        JLabel noMalwareLabel = new JLabel(
                "                                                    No Malware Detected");
        noMalwareLabel.setFont(noMalwareFont);
        noMalwareLabel.setPreferredSize(new Dimension(WIDTH, 100));
        graphPanel4.add(noMalwareLabel, BorderLayout.NORTH);
        JPanel emptyPanel = new JPanel();
        emptyPanel.setPreferredSize(new Dimension(50, 200));
        emptyPanel.setOpaque(true);
        graphPanel4.add(emptyPanel, BorderLayout.SOUTH);
    }
    MalwarePanel.add(graphPanel4, BorderLayout.CENTER);
    ChartPanel fourthPanel = mvp.getPanel4(metric4);

    fourthPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            dashboardTabs.setSelectedIndex(4);
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    Metric4Panel.setLayout(new BorderLayout());
    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel malwareTitleLabel = new JLabel("    Malware Detection");
    malwareTitleLabel.setFont(titleFont);
    Metric4Panel.add(malwareTitleLabel, BorderLayout.PAGE_START);
    Metric4Panel.add(fourthPanel, BorderLayout.CENTER);
    if (metric4.getTotalCount() == 0) {
        Font noMalwareFont = new Font("Calibri", Font.BOLD, 20);
        JLabel noMalwareLabel = new JLabel("       No Malware Detected");
        noMalwareLabel.setFont(noMalwareFont);
        Metric4Panel.add(noMalwareLabel, BorderLayout.SOUTH);
    }
    Metric4Panel.setBackground(Color.white);
}

From source file:UI.SecurityDashboard.java

private void performMetric9() {
    GZDecompression m9 = new GZDecompression();
    String[][] counts = m9.getMetric9();

    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel logAuditTitleLabel = new JLabel("                Log Audit");
    logAuditTitleLabel.setFont(titleFont);

    AreaChart areaChart = new AreaChart(m9.getLogCount(), m9.getSuccessCount(), m9.getFailCount());
    ChartPanel thisChart = areaChart.drawAreaChart();
    thisChart.setBackground(Color.white);

    thisChart.addChartMouseListener(new ChartMouseListener() {

        @Override//from  www.  jav  a  2  s. c o  m
        public void chartMouseClicked(ChartMouseEvent cme) {
            dashboardTabs.setSelectedIndex(9);
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    Metric9Panel.setBackground(Color.WHITE);
    Metric9Panel.setLayout(new BorderLayout());
    Metric9Panel.add(logAuditTitleLabel, BorderLayout.NORTH);
    Metric9Panel.add(thisChart, BorderLayout.CENTER);
    Metric9Panel.setEnabled(false);

    String[] columns = { "Log Failure" };
    JTable table = new JTable(counts, columns);
    table.setShowHorizontalLines(true);
    table.setRowHeight(40);
    table.setEnabled(false);
    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    AuditPanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nThrough the analysis of security logs, this page will show an audit of the attack attempts and "
                    + "security breaches. The logs provide critical information related to system events that can be used to track suspicicous "
                    + "activities.\n");
    header.setLineWrap(true);
    header.setWrapStyleWord(true);
    header.setEditable(false);
    AuditPanel.add(header, BorderLayout.NORTH);
    AuditPanel.add(tableScrollPane, BorderLayout.CENTER);
}

From source file:UI.SecurityDashboard.java

private void performMetric7(MainViewPanel mvp) {
    Metric7 metric7 = new Metric7();

    JPanel graphPanel7 = new JPanel();
    graphPanel7.setLayout(new BorderLayout());
    graphPanel7.add(metric7.run(), BorderLayout.NORTH);

    PortPanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nOpen ports that are not being used by a secure service on a system may result in a malicious "
                    + "attacker gaining access to the network. By listing all open ports on each device, this can aid in ensuring that ports "
                    + "currently open are know of.\n");
    header.setLineWrap(true);
    header.setWrapStyleWord(true);/*from   w  w w  .  ja  v  a  2 s . c o m*/
    header.setEditable(false);
    PortPanel.add(header, BorderLayout.NORTH);
    PortPanel.add(graphPanel7, BorderLayout.CENTER);

    Metric7Panel.setBackground(Color.WHITE);
    Metric7Panel.setLayout(new BorderLayout());

    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel portTitleLabel = new JLabel("              Open Ports");
    portTitleLabel.setFont(titleFont);

    Metric7Panel.add(portTitleLabel, BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel emptyLabel = new JLabel(" ");
    JLabel emptyLabel2 = new JLabel(" ");
    JLabel emptyLabel3 = new JLabel("   ");
    JLabel emptyLabel4 = new JLabel("   ");

    emptyLabel.setBackground(Color.white);
    emptyLabel2.setBackground(Color.white);
    emptyLabel3.setBackground(Color.white);
    emptyLabel4.setBackground(Color.white);

    emptyLabel.setOpaque(true);
    emptyLabel2.setOpaque(true);
    emptyLabel3.setOpaque(true);
    emptyLabel4.setOpaque(true);

    p.add(emptyLabel, BorderLayout.NORTH);
    p.add(emptyLabel3, BorderLayout.WEST);
    p.add(mvp.getPanel7(metric7), BorderLayout.CENTER);
    p.add(emptyLabel4, BorderLayout.EAST);
    p.add(emptyLabel2, BorderLayout.SOUTH);
    Metric7Panel.add(p, BorderLayout.CENTER);
    Metric7Panel.setBackground(Color.white);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTextArea.java

@Override
protected JTextArea createTextComponentImpl() {
    final JTextArea impl = new TextAreaFlushableField();

    if (isTabTraversal()) {
        Set<KeyStroke> forwardFocusKey = Collections.singleton(getKeyStroke(KeyEvent.VK_TAB, 0));
        impl.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardFocusKey);

        Set<KeyStroke> backwardFocusKey = Collections
                .singleton(getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK));
        impl.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardFocusKey);

        impl.addKeyListener(new KeyAdapter() {
            @Override/*from   w w  w  .ja  v a 2s. com*/
            public void keyPressed(KeyEvent e) {
                if (isEnabled() && isEditable() && e.getKeyCode() == KeyEvent.VK_TAB
                        && e.getModifiers() == KeyEvent.CTRL_MASK) {

                    if (StringUtils.isEmpty(impl.getText())) {
                        impl.setText("\t");
                    } else {
                        impl.append("\t");
                    }
                }
            }
        });
    }

    impl.setLineWrap(true);
    impl.setWrapStyleWord(true);

    int height = (int) impl.getPreferredSize().getHeight();
    impl.setMinimumSize(new Dimension(0, height));

    composition = new JScrollPane(impl);
    composition.setPreferredSize(new Dimension(150, height));
    composition.setMinimumSize(new Dimension(0, height));

    doc.putProperty("filterNewlines", false);

    return impl;
}

From source file:algorithm.QRCodeWatermarking.java

/**
 * Creates the GUI that is used to configure this algorithm.
 *//* w w  w.  j  a  v  a  2s. c o m*/
private void createConfigurationGui() {
    initButtons();
    panel = new GUIPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.gridwidth = 2;
    panel.add(new JLabel("<html><h2>QR-code options</h2></html>"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("QR-code size: "), constraints);
    constraints.gridx++;
    sizeField.setText("200");
    panel.add(sizeField, constraints);
    constraints.gridwidth = 2;
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    constraints.gridx = 0;
    constraints.gridwidth = 1;
    panel.add(new JLabel("Select output file format:"), constraints);
    constraints.gridx++;
    panel.add(imageFormatBox, constraints);
    constraints.gridx = 0;
    constraints.gridy++;

    // separate file:
    constraints.gridwidth = 2;
    panel.add(falseEncapsulate, constraints);
    constraints.gridy++;
    constraints.gridy++;

    // add to carrier:
    panel.add(trueEncapsulate, constraints);
    constraints.gridy++;

    JTextArea infoArea = new JTextArea();
    infoArea.setText("" + "\nPlease note: "
            + "\n- The QR-code will be created from the first payload file, if the dataset has more than one payload files, and added to each carrier file. "
            + "All other payload files will be ignored, if this option is selected."
            + "\n- Carrier files need to be one of the following file types:"
            + "\n\tpng, jpeg, jp2, jpg, bmp, gif" + "\n- All carrier files of other file formats are ignored."
            + "\n- The QR-code pixel size should exceed the carrier image size in no dimension."
            + "\n- If the size of the selected payload file is too big to create a QR-code from it, you will get an error message."
            + "\n\n" + "Options for adding the QR-code to the carrier images:");
    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    panel.add(infoArea, constraints);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridy++;
    panel.add(new JLabel("On which image position should the barcode be added?"), constraints);
    constraints.gridy++;
    constraints.gridwidth = 1;
    panel.add(new JLabel("X :"), constraints);
    constraints.gridx++;
    xPositionField.setText("0");
    panel.add(xPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    panel.add(new JLabel("Y :"), constraints);
    constraints.gridx++;
    yPositionField.setText("0");
    panel.add(yPositionField, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridy++;
    panel.add(messageLabel, constraints);
}

From source file:UI.SecurityDashboard.java

private void performMetric6(MainViewPanel mvp) {
    Metric6 metric6 = new Metric6();

    JPanel graphPanel6 = new JPanel();
    graphPanel6.setLayout(new BorderLayout());
    graphPanel6.add(metric6.run(), BorderLayout.NORTH);

    DefencePanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nThe network defence panel is designated to analysing network devices such as Firewalls, Routers, "
                    + "and Switches, and helps to ensure that the boundary defence is the work is well maintained. These devices must be updated "
                    + "correctly configured in order to prevent unauthorised external access.\n");
    header.setLineWrap(true);
    header.setWrapStyleWord(true);//w  ww.  j a va2  s . c o  m
    header.setEditable(false);
    DefencePanel.add(header, BorderLayout.NORTH);
    DefencePanel.add(graphPanel6, BorderLayout.CENTER);

    ChartPanel sixthPanel = mvp.getPanel6(metric6);

    sixthPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            dashboardTabs.setSelectedIndex(6);
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    Metric6Panel.setLayout(new BorderLayout());
    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel netDefTitleLabel = new JLabel("           Network Defence");
    netDefTitleLabel.setFont(titleFont);
    Metric6Panel.add(netDefTitleLabel, BorderLayout.NORTH);
    Metric6Panel.add(sixthPanel, BorderLayout.CENTER);
    Metric6Panel.setBackground(Color.white);
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void showSoilDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSoilDataButtonActionPerformed
    // TODO add your handling code here:

    boolean isFileEnabled = jRadioFile.isSelected();
    boolean isFileLocationEnabled = jRadioButtonSavedLocation.isSelected();
    String str = "";

    if (isFileLocationEnabled) {
        SoilData soilData;/*from  w  w w. j a va2 s.  c o  m*/
        File latestFile;
        try {
            latestFile = findLatestFile(soilFileListCombo.getSelectedIndex());
            str = readFromJsonFileForSoilDetailsButton(latestFile);

        } catch (FileNotFoundException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
            return;
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (isFileEnabled) {
        str += "Soil Name = " + SNAME + "\n";
        str += "Texture = " + TXT[0] + "\n";
        str += "Number of Layers = " + NL + "\n";
        str += "    DU        WCL        WCU        (WCU-WCL)\n";
        for (int i = 0; i < NL; i++) {
            str += (i + 1) + "  " + DU[i] + "       " + WCL[i] + "       " + WCU[i] + "       "
                    + (WCU[i] - WCL[i]) + "\n";
        }
    }

    JTextArea textArea = new JTextArea(str);
    JScrollPane scrollPane = new JScrollPane(textArea);
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    textArea.setWrapStyleWord(true);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    JOptionPane.showMessageDialog(null, scrollPane, "Soil Info", JOptionPane.NO_OPTION);

    //JOptionPane.showMessageDialog(null, str);            

}

From source file:UI.SecurityDashboard.java

private void performMetric3(MainViewPanel mvp) {
    Metric3 metric3 = new Metric3();

    JPanel graphPanel3 = new JPanel();
    graphPanel3.setLayout(new BorderLayout());
    graphPanel3.add(metric3.run(), BorderLayout.NORTH);

    AntiVirusPanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nThis page lists all devices on the network, divided into two tables. The top table shows the "
                    + "critical issues where the devices listed are either not running an anti-virus solution or the solution is not updated. It "
                    + "will also list those anti-virus solutions which have services which are not running (Scanning is disabled). The bottom "
                    + "table shows the updated table where the devices listed have updated and running anti-virus solutions.\n");
    header.setLineWrap(true);
    header.setWrapStyleWord(true);/*from  w w w. j  a va2 s.  com*/
    header.setEditable(false);
    AntiVirusPanel.add(header, BorderLayout.NORTH);
    AntiVirusPanel.add(graphPanel3, BorderLayout.CENTER);

    ChartPanel thirdPanel = mvp.getPanel3(metric3);

    thirdPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            dashboardTabs.setSelectedIndex(3);
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    Metric3Panel.setLayout(new BorderLayout());
    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel avTitleLabel = new JLabel("           AV Scan Check");
    avTitleLabel.setFont(titleFont);
    Metric3Panel.add(avTitleLabel, BorderLayout.NORTH);
    Metric3Panel.add(thirdPanel, BorderLayout.CENTER);
    Metric3Panel.setBackground(Color.white);
}

From source file:gui.LauncherFrame.java

/**
 * creates a text pane containing text and adds it to a tabbed frame
 * //  www .  j a  v a2 s  . c  o m
 * @param tabbedPane - the tabbed frame to add the text panel to
 * @param tabName  - title of the text panel tab
 * @param filename - name of file containing the text to add to the text panel
 */
private void addTextTab(javax.swing.JTabbedPane tabbedPane, String tabName, String filename) {

    File textfile = new File(filename);
    if (!textfile.isFile()) {
        debug.print(DebugMessage.StatusType.Error, "File is not valid: " + filename);
        return;
    }
    if (tabName == null || tabName.isEmpty()) {
        debug.print(DebugMessage.StatusType.Error, "Invalid name for tab: " + tabName);
        return;
    }

    BufferedReader in = null;
    try {
        // create a text area and place it in a scrollable panel
        javax.swing.JTextArea fileText = new javax.swing.JTextArea(0, 0);
        fileText.setLineWrap(true);
        fileText.setWrapStyleWord(true);
        javax.swing.JScrollPane fileScroll = new javax.swing.JScrollPane(fileText);

        // place the scroll pane in the tabbed pane
        tabbedPane.addTab(tabName, fileScroll);

        // now read the file contents into the text area
        in = new BufferedReader(new FileReader(textfile));
        String line = in.readLine();
        while (line != null) {
            fileText.append(line + "\n");
            line = in.readLine();
        }
        fileText.setCaretPosition(0); // set position to start of file
    } catch (FileNotFoundException ex) {
        debug.print(DebugMessage.StatusType.Error, ex + "<FILE_NOT_FOUND> - accessing " + tabName + " file");
    } catch (IOException ex) {
        debug.print(DebugMessage.StatusType.Error, ex + "<IO_EXCEPTION>");
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ex) {
                debug.print(DebugMessage.StatusType.Error, ex + "<IO_EXCEPTION>");
            }
        }
    }
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

/**
 * Creates a JTextArea for display purposes only.
 * @param cellField FormCellField info// w w  w .  ja  v  a2  s . co  m
 * @return the control
 */
public static JScrollPane changeTextAreaForDisplay(final JTextArea ta) {
    Insets insets = ta.getBorder().getBorderInsets(ta);
    ta.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.bottom));
    ta.setForeground(Color.BLACK);
    ta.setEditable(false);
    ta.setBackground(viewFieldColor.getColor());
    ta.setLineWrap(true);
    ta.setWrapStyleWord(true);

    JScrollPane scrollPane = new JScrollPane(ta);
    insets = scrollPane.getBorder().getBorderInsets(scrollPane);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane
            .setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.bottom));

    return scrollPane;
}