Example usage for javax.swing JTextArea setBounds

List of usage examples for javax.swing JTextArea setBounds

Introduction

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

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

Moves and resizes this component.

Usage

From source file:com.milkdairy.collectionsmodule.CollectionsUpdateFormJPanel.java

public JTextArea addComponent(JTextArea comp, int xx, int yy, int width, int height) {
    comp = new JTextArea(30, 10);
    comp.setBounds(xx, yy, width, height);
    // comp.setOpaque(true);
    this.add(comp);
    return comp;/*from  w  w  w.j  a  v a 2 s .  c o m*/
}

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. java 2s  . 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);

}