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:medsavant.uhn.cancer.UserCommentApp.java

private JPanel getCommentPanel(UserComment lc) {
    JTextArea commentText = new JTextArea();
    commentText.setText(lc.getCommentText());
    commentText.setEditable(false);/* w w  w  . java 2s . c  o m*/
    commentText.setLineWrap(true);
    commentText.setPreferredSize(new Dimension(COMMENTTEXT_PREFERRED_WIDTH, COMMENTTEXT_PREFERRED_HEIGHT));
    JScrollPane jsp = new JScrollPane(commentText);

    JPanel outerCommentPanel = new JPanel();
    outerCommentPanel.setLayout(new BoxLayout(outerCommentPanel, BoxLayout.X_AXIS));
    outerCommentPanel.add(jsp);
    outerCommentPanel.add(Box.createHorizontalGlue());
    return outerCommentPanel;
}

From source file:net.aepik.alasca.gui.util.LoadFileFrame.java

/**
 * Initialize frame content./* w  w  w .ja v  a 2  s.  com*/
 */
private void initFrame() {
    // - Panel bouton du bas -

    JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    boutonsPanel.add(boutonOk);
    boutonsPanel.add(boutonAnnuler);

    // - Panel nom du fichier -

    JTextArea textAreaFilename = new JTextArea(
            "Indiquez le nom du fichier contenant les dfinitions du schma LDAP que vous souhaitez charger.");
    textAreaFilename.setEditable(false);
    textAreaFilename.setLineWrap(true);
    textAreaFilename.setWrapStyleWord(true);
    textAreaFilename.setFont((new JLabel()).getFont());
    textAreaFilename.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6));
    textAreaFilename.setBackground(new Color(240, 235, 226));

    boutonOpenFile.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 5, 0, 0, boutonsPanel.getBackground()),
            boutonOpenFile.getBorder()));

    JPanel filenamePanel = new JPanel(new BorderLayout());
    filenamePanel.add(textAreaFilename, BorderLayout.NORTH);
    filenamePanel.add(filename, BorderLayout.CENTER);
    filenamePanel.add(boutonOpenFile, BorderLayout.EAST);
    filenamePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Schma LDAP "),
                    BorderFactory.createEmptyBorder(0, 5, 5, 5))));

    // - Panel du selecteur de syntaxes -

    JTextArea textAreaSyntaxes = new JTextArea(
            "Il vous faut appliquer un filtre sur le schma que vous voulez charger. Voici la liste des filtres disponibles :");
    textAreaSyntaxes.setEditable(false);
    textAreaSyntaxes.setLineWrap(true);
    textAreaSyntaxes.setWrapStyleWord(true);
    textAreaSyntaxes.setFont((new JLabel()).getFont());
    textAreaSyntaxes.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6));
    textAreaSyntaxes.setBackground(new Color(240, 235, 226));

    JPanel syntaxesPanel = new JPanel(new BorderLayout());
    syntaxesPanel.add(textAreaSyntaxes, BorderLayout.NORTH);
    syntaxesPanel.add(syntaxes);
    syntaxesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Syntaxe LDAP "),
                    BorderFactory.createEmptyBorder(0, 5, 5, 5))));

    // On injecte le nom des classes de syntaxes possibles
    // dynamiquement.
    String[] syntaxesName = Schema.getSyntaxeNames();
    for (int i = 0; syntaxesName != null && i < syntaxesName.length; i++) {
        syntaxes.addItem(syntaxesName[i]);
    }

    // - Organisation gnrale -

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(filenamePanel, BorderLayout.NORTH);
    mainPanel.add(syntaxesPanel, BorderLayout.CENTER);

    JPanel mainPanelContainer = new JPanel(new BorderLayout());
    mainPanelContainer.add(mainPanel, BorderLayout.NORTH);
    mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH);
    mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1));

    getContentPane().add(new DescriptiveInternalFrame(mainFrame.getIconImage(),
            "Slectionner un fichier et sa syntaxe.", mainPanelContainer));

    // - Listeners -

    addWindowListener(this);
    boutonOpenFile.addActionListener(this);
    boutonOk.addActionListener(this);
    boutonAnnuler.addActionListener(this);
}

From source file:fll.scheduler.ChooseChallengeDescriptor.java

private void initComponents() {
    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;//from w  w w. j av  a  2s.  c om
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    final JTextArea instructions = new JTextArea(
            "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.",
            3, 40);
    instructions.setEditable(false);
    instructions.setWrapStyleWord(true);
    instructions.setLineWrap(true);
    getContentPane().add(instructions, gbc);

    gbc = new GridBagConstraints();
    mCombo = new JComboBox<DescriptionInfo>();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(mCombo, gbc);
    mCombo.setRenderer(new DescriptionInfoRenderer());
    mCombo.setEditable(false);
    final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo();
    for (final DescriptionInfo info : descriptions) {
        mCombo.addItem(info);
    }

    mFileField = new JLabel();
    gbc = new GridBagConstraints();
    gbc.weightx = 1;
    getContentPane().add(mFileField, gbc);

    final JButton chooseButton = new JButton("Choose File");
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(chooseButton, gbc);
    chooseButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mFileField.setText(null);

            final JFileChooser fileChooser = new JFileChooser();
            final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" });
            fileChooser.setFileFilter(filter);

            final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File selectedFile = fileChooser.getSelectedFile();
                mFileField.setText(selectedFile.getAbsolutePath());
            }
        }
    });

    final Box buttonPanel = new Box(BoxLayout.X_AXIS);
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(buttonPanel, gbc);

    buttonPanel.add(Box.createHorizontalGlue());
    final JButton ok = new JButton("Ok");
    buttonPanel.add(ok);
    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {

            // use the selected description if nothing is entered in the file box
            final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex());
            if (null != descriptionInfo) {
                mSelected = descriptionInfo.getURL();
            }

            final String text = mFileField.getText();
            if (!StringUtils.isEmpty(text)) {
                final File file = new File(text);
                if (file.exists()) {
                    try {
                        mSelected = file.toURI().toURL();
                    } catch (final MalformedURLException e) {
                        throw new FLLInternalException("Can't turn file into URL?", e);
                    }
                }
            }

            setVisible(false);
        }
    });

    final JButton cancel = new JButton("Cancel");
    buttonPanel.add(cancel);
    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mSelected = null;
            setVisible(false);
        }
    });

    pack();
}

From source file:coreferenceresolver.gui.MarkupGUI.java

private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException {
    //Model/*  w w w  . j  a v  a  2s  .  co m*/
    ReviewElement reviewElement = new ReviewElement();

    ScrollablePanel reviewPanel = new ScrollablePanel();
    reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS));

    JTextField title = new JTextField("NEW REVIEW " + reviewId);
    title.setBackground(Color.pink);

    reviewPanel.add(title);

    JTextArea reviewContentTxtArea = new JTextArea();
    reviewContentTxtArea.setLineWrap(true);
    reviewContentTxtArea.setWrapStyleWord(true);
    reviewContentTxtArea.setEditable(false);
    reviewContentTxtArea.setText(review.getRawContent());

    int chainId = 0;
    for (CorefChain cc : review.getCorefChains()) {
        for (int npId : cc.getChain()) {
            NounPhrase np = review.getNounPhrases().get(npId);
            Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(),
                    np.getOffsetEnd() + 1, highlightPainters.get(chainId));
            this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag;
        }
        ++chainId;
    }

    reviewPanel.add(reviewContentTxtArea);

    ScrollablePanel markupsPanel = new ScrollablePanel();
    markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS));

    for (int i = 0; i < review.getNounPhrases().size(); ++i) {
        JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement);
        markupsPanel.add(newMarkupPanel);
    }

    JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel);

    //Add Dimension for scrolling
    Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400));

    reviewPanel.add(scrollMarkupsPanel);

    //MODEL
    reviewElement.reviewTextArea = reviewContentTxtArea;
    reviewElements.add(reviewElement);

    reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL));

    reviewPanel.add(Box.createVerticalStrut(20));

    JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel);

    return scrollReviewPanel;
}

From source file:hspc.submissionsprogram.AppDisplay.java

AppDisplay() {
    this.setTitle("Dominion High School Programming Contest");
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setResizable(false);

    WindowListener exitListener = new WindowAdapter() {
        @Override//from www. jav  a 2 s.  c o  m
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    this.addWindowListener(exitListener);

    JTabbedPane pane = new JTabbedPane();
    this.add(pane);

    JPanel submitPanel = new JPanel(null);
    submitPanel.setPreferredSize(new Dimension(500, 500));

    UIManager.put("FileChooser.readOnly", true);
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setBounds(0, 0, 500, 350);
    fileChooser.setVisible(true);
    FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java");
    fileChooser.setFileFilter(javaFilter);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setControlButtonsAreShown(false);
    submitPanel.add(fileChooser);

    JSeparator separator1 = new JSeparator();
    separator1.setBounds(12, 350, 476, 2);
    separator1.setForeground(new Color(122, 138, 152));
    submitPanel.add(separator1);

    JLabel problemChooserLabel = new JLabel("Problem:");
    problemChooserLabel.setBounds(12, 360, 74, 25);
    submitPanel.add(problemChooserLabel);

    String[] listOfProblems = Main.Configuration.get("problem_names")
            .split(Main.Configuration.get("name_delimiter"));
    JComboBox problems = new JComboBox<>(listOfProblems);
    problems.setBounds(96, 360, 393, 25);
    submitPanel.add(problems);

    JButton submit = new JButton("Submit");
    submit.setBounds(170, 458, 160, 30);
    submit.addActionListener(e -> {
        try {
            File file = fileChooser.getSelectedFile();
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url"));

                MultipartEntityBuilder builder = MultipartEntityBuilder.create();
                builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN);
                builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()),
                        ContentType.TEXT_PLAIN);
                builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
                HttpEntity multipart = builder.build();

                uploadFile.setEntity(multipart);

                CloseableHttpResponse response = httpClient.execute(uploadFile);
                HttpEntity responseEntity = response.getEntity();
                String inputLine;
                BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
                try {
                    if ((inputLine = br.readLine()) != null) {
                        int rowIndex = Integer.parseInt(inputLine);
                        new ResultWatcher(rowIndex);
                    }
                    br.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    });
    submitPanel.add(submit);

    JPanel clarificationsPanel = new JPanel(null);
    clarificationsPanel.setPreferredSize(new Dimension(500, 500));

    cList = new JList<>();
    cList.setBounds(12, 12, 476, 200);
    cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    cList.setBackground(new Color(254, 254, 255));
    clarificationsPanel.add(cList);

    JButton viewC = new JButton("View");
    viewC.setBounds(12, 224, 232, 25);
    viewC.addActionListener(e -> {
        if (cList.getSelectedIndex() != -1) {
            int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]);
            clarificationDatas.stream().filter(data -> data.getId() == id).forEach(
                    data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse()));
        }
    });
    clarificationsPanel.add(viewC);

    JButton refreshC = new JButton("Refresh");
    refreshC.setBounds(256, 224, 232, 25);
    refreshC.addActionListener(e -> updateCList(true));
    clarificationsPanel.add(refreshC);

    JSeparator separator2 = new JSeparator();
    separator2.setBounds(12, 261, 476, 2);
    separator2.setForeground(new Color(122, 138, 152));
    clarificationsPanel.add(separator2);

    JLabel problemChooserLabelC = new JLabel("Problem:");
    problemChooserLabelC.setBounds(12, 273, 74, 25);
    clarificationsPanel.add(problemChooserLabelC);

    JComboBox problemsC = new JComboBox<>(listOfProblems);
    problemsC.setBounds(96, 273, 393, 25);
    clarificationsPanel.add(problemsC);

    JTextArea textAreaC = new JTextArea();
    textAreaC.setLineWrap(true);
    textAreaC.setWrapStyleWord(true);
    textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    textAreaC.setBackground(new Color(254, 254, 255));

    JScrollPane areaScrollPane = new JScrollPane(textAreaC);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setBounds(12, 312, 477, 134);
    clarificationsPanel.add(areaScrollPane);

    JButton submitC = new JButton("Submit Clarification");
    submitC.setBounds(170, 458, 160, 30);
    submitC.addActionListener(e -> {
        if (textAreaC.getText().length() > 2048) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        } else if (textAreaC.getText().length() < 20) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.",
                    "Error", JOptionPane.WARNING_MESSAGE);
        } else {
            Connection conn = null;
            PreparedStatement stmt = null;
            try {
                Class.forName(JDBC_DRIVER);

                conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"),
                        Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass"));

                String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)";
                stmt = conn.prepareStatement(sql);

                stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID)));
                stmt.setString(2, String.valueOf(problemsC.getSelectedItem()));
                stmt.setString(3, String.valueOf(textAreaC.getText()));

                textAreaC.setText("");

                stmt.executeUpdate();

                stmt.close();
                conn.close();

                updateCList(false);
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (stmt != null) {
                        stmt.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
            }
        }
    });
    clarificationsPanel.add(submitC);

    pane.addTab("Submit", submitPanel);
    pane.addTab("Clarifications", clarificationsPanel);

    Timer timer = new Timer();
    TimerTask updateTask = new TimerTask() {
        @Override
        public void run() {
            updateCList(false);
        }
    };
    timer.schedule(updateTask, 10000, 10000);

    updateCList(false);

    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
}

From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java

private void initialiseUI() {
    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.weightx = 1.0;/*  w  w  w.j  av a  2s .co  m*/

    c.gridx = 0;
    c.gridy = 0;
    JTextArea taDescription = new JTextArea("Configure the Service Catalogue integration functionality");
    taDescription.setFont(taDescription.getFont().deriveFont(Font.PLAIN, 11));
    taDescription.setLineWrap(true);
    taDescription.setWrapStyleWord(true);
    taDescription.setEditable(false);
    taDescription.setFocusable(false);
    taDescription.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(taDescription, c);

    c.gridy++;
    c.insets = new Insets(20, 0, 0, 0);
    JLabel jlBioCatalogueAPIBaseURL = new JLabel("Base URL of the Service Catalogue instance to connect to:");
    this.add(jlBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(0, 0, 0, 0);
    tfBioCatalogueAPIBaseURL = new JTextField();
    this.add(tfBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(30, 0, 0, 0);
    // We are not removing BioCatalogue services from its config panel any more - 
    // they are being handled by the Taverna's Service Registry
    //    JButton bForgetStoredServices = new JButton("Forget services added to Service Panel by BioCatalogue Plugin");
    //    bForgetStoredServices.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e)
    //      {
    //        int response = JOptionPane.showConfirmDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                                       "Are you sure you want to clear all SOAP operations and REST methods\n" +
    //                                       "that were added to the Service Panel by the BioCatalogue Plugin?\n\n" +
    //                                       "This action is permanent is cannot be undone.\n\n" +
    //                                       "Do you want to proceed?", "BioCatalogue Plugin", JOptionPane.YES_NO_OPTION);
    //        
    //        if (response == JOptionPane.YES_OPTION)
    //        {
    //          BioCatalogueServiceProvider.clearRegisteredServices();
    //          JOptionPane.showMessageDialog(null,  // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                          "Stored services have been successfully cleared, but will remain\n" +
    //                          "being shown in Service Panel during this session.\n\n" +
    //                          "They will not appear in the Service Panel after you restart Taverna.",
    //                          "BioCatalogue Plugin", JOptionPane.INFORMATION_MESSAGE);
    //        }
    //      }
    //    });
    //    this.add(bForgetStoredServices, c);

    JButton bLoadDefaults = new JButton("Load Defaults");
    bLoadDefaults.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadDefaults();
        }
    });

    JButton bReset = new JButton("Reset");
    bReset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetFields();
        }
    });

    JButton bApply = new JButton("Apply");
    bApply.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyChanges();
        }
    });

    JPanel jpActionButtons = new JPanel();
    jpActionButtons.add(bLoadDefaults);
    jpActionButtons.add(bReset);
    jpActionButtons.add(bApply);
    c.insets = new Insets(30, 0, 0, 0);
    c.gridy++;
    c.weighty = 1.0;
    this.add(jpActionButtons, c);
}

From source file:org.openmeetings.app.data.record.BatikMethods.java

public void drawTextByJTextArea(Graphics2D g2d, int x, int y, int width, int height, String text,
        String default_export_font, int style, int size, Color fontColor) throws Exception {

    //      g2d.setClip(x, y, width, height);
    //      g2d.setColor(Color.black);
    //      g2d.drawString(text, x, y+20);

    //Font font = new Font("Verdana", Font.PLAIN, 11);
    Font font = new Font(default_export_font, style, size);

    String[] stringsText = text.split("\r");
    //log.debug("TEXT: "+stringsText);
    //log.debug("TEXT: "+stringsText.length);

    String newText = "";

    for (int i = 0; i < stringsText.length; i++) {
        newText += stringsText[i];/*from ww w.j ava 2 s.co  m*/
        if (i + 1 < stringsText.length) {
            newText += "\n";
        }
    }

    JTextArea n = new JTextArea(newText);
    n.setFont(font);
    n.setWrapStyleWord(true);
    n.setLineWrap(true);
    n.setForeground(fontColor);

    //log.debug("Text at: "+x+" "+y);
    //int x, int y, int width, int height
    n.setBounds(x, y, width, height);
    n.setOpaque(false);

    //Text
    SVGGraphics2D svgGenerator2 = (SVGGraphics2D) g2d.create(x, y, width, height);

    //svgGenerator2.create(x, y, width, height);
    //svgGenerator2.draw(.dra)
    n.paint(svgGenerator2);

}

From source file:com.mindcognition.mindraider.ui.swing.concept.annotation.renderer.AbstractTextAnnotationRenderer.java

private void configureEditor(JTextArea annotationTextArea) {
    // TODO use colors from the configuration
    annotationTextArea.setForeground(Color.WHITE);
    annotationTextArea.setBackground(Color.BLACK);
    annotationTextArea.setCaretColor(Color.RED);
    annotationTextArea.setSelectionColor(Color.YELLOW);
    annotationTextArea.setLineWrap(true);
    annotationTextArea.setWrapStyleWord(true);
    annotationTextArea.setFont(TEXTAREA_FONT);
    ;//  www  .j a va2  s . c  o m

    // undo and redo
    undoManager = new UndoManager();
    annotationTextArea.getDocument().addUndoableEditListener(new EditorUndoListner(undoManager, toolbar));
}

From source file:components.TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);/*from   w  w w .  java2 s.  c o m*/

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text in a field and press Enter.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}

From source file:hermes.renderers.DefaultMessageRenderer.java

/**
 * Show a BytesMessage either as a java object or just a size.
 * /*  ww w .j  ava 2  s . co m*/
 * @param parent
 * 
 * @param bytesMessage
 * @return
 * @throws JMSException
 * @throws IOException
 * @throws ClassNotFoundException
 */
protected JComponent handleBytesMessage(JScrollPane parent, BytesMessage bytesMessage)
        throws JMSException, IOException, ClassNotFoundException {
    final MyConfig currentConfig = (MyConfig) getConfig();

    JTextArea textPane = new MyTextArea();

    textPane.setEditable(false);
    textPane.setWrapStyleWord(true);
    textPane.setLineWrap(true);
    bytesMessage.reset();

    if (currentConfig.isBytesIsObject()) {
        final byte[] bytes = MessageUtils.asBytes(bytesMessage);
        final ByteArrayInputStream bistream = new ByteArrayInputStream(bytes);
        final ObjectInputStream oistream = new ObjectInputStream(bistream);
        final Object o = oistream.readObject();

        textPane.setText(o.toString());
    } else if (currentConfig.isBytesIsString()) {
        try {
            String text = new String(MessageUtils.asBytes(bytesMessage), currentConfig.getBytesEncoding());
            textPane.setText(text);
            return textPane;
        } catch (JMSException e) {
            textPane.setText(e.getMessage());
        }
    } else {
        HexMessageRenderer renderer = new HexMessageRenderer();
        textPane = (JTextArea) renderer.render(parent, bytesMessage); // Hack.
    }

    textPane.setCaretPosition(0);

    return textPane;
}