textarea /textarea problem!

Hi! This might seem simple enough
but I can't seem to figure it out:
I have written a form in a jsp-page.
In the there are a couple of fields
and a textarea, i'm using the method
post. The thing is that when i process
the form-input all the carriage returns
in the textarea has vanished and the
text is displayed as if it were
written in one single row.
Why is this
and how can it be fixed?
/Andreas

Hi ,
try this...........
write a javascript method................
in the below method 'specialProvision' is the textarea name....
function formatText(){
     var frm = document.forms[0];
     var temp="";
     var i=0;
     var spProv = frm.specialProvision.value;
     while(spProv.indexOf("\n")!=-1){
          i=spProv.indexOf("\n");
          temp += spProv.slice(0,i-1);
          temp += "|||";
          spProv = spProv.slice(i+1,spProv.length)
     temp += spProv;
     frm.spProv.value =temp;
while sending it to the database say in in the save method....
function save(){
formatText();
document.forms[0].action = 'here your target path may be to a servlet';
document.forms[0].submit();
and while showing in the textarea use this method.................
showText('here your textarea value ie in the database');
// the text area value will be stored with ||| in between .....in the database....
function showText(val){
     while(val.indexOf("|||")!=-1){
          val = val.replace("|||","\n");
     return val;
and from the above method it will show as it is you typed into the textarea...............
if you still have pbs contact me at : [email protected]
Thank you
Ravikiran

Similar Messages

  • HTML input textarea causes problems

    Hi,
    I have a textarea on my form where the user will have the opportunity to enter a paragraph of text, where he can use HTML tags and whatever. But as soon as I enter html tags into this area, the formfileds coming after this textarea cannot sent their parameters to the next procedure. No html tags, everything works fine.
    Any idea?

    Hi Nilay,
    I don't think the textarea has anything to do with your problem. I just tried out and it works fine for me (at least with the italic and strong tags). Could you provide some more information on your case? (HTML source, the way you process the parameters, etc.)
    Peter

  • TextArea Scrollbar problem

    I am starting to elarn flex and as a learning project I decided to make a simple RSS reader for one of my websites. I plan to release it as an Android app. The thing is I found a small problem with a textArea that has HTML text inside it. The text get's trimmed to the lenght that fits inside the text area. On the emulator, pressing the up/down arrow keys will make the textarea to render corectly just like it should...but on my tablet, there isn't a keyboard and even if it was it would not be OK to make this. Here is part of my code:
    protected function newstext_showHandler(event:FlexEvent):void
         // TODO Auto-generated method stub
         var title:String = String(data[0]);
         var content:String = String(data[1]);
         this.title = title;
         StyleableTextField(newstext.textDisplay).htmlText = content;
    data is an array passed from a previous screen. data[1] contains the HTML code.
    The TextArea is added with these properties:
    <s:TextArea id="newstext" x="0" y="0" width="100%" height="100%" editable="false" enabled="true" selectable="false" addedToStage="newstext_addedToStageHandler(event)" verticalScrollPolicy="on"/>
    I also attached two images to show what I mean. In the first pic even if I try to scroll down no text is displayed. In the seccond, right after I press the up/down arrow keys a new line appears rendered and if I scroll down the entire article is shown.
    http://imageshack.us/photo/my-images/195/beforearrowpressed.jpg/
    http://imageshack.us/photo/my-images/849/afterarrowpressed.jpg/
    If anyone has a fix for this please let me know.

    May be you have to create a resizable text area.
    http://idletogether.com/automatically-resize-texttextarea-based-on-content-autosize-in-fle x/
    http://www.flexer.info/2009/02/06/auto-resizable-text-area-component/

  • TextArea printing problem?

    Hello,
    I am facing a problem while printing the content of TextArea. My textarea contains large data to be printed with same formatting.
    my code
    var printJob:FlexPrintJob = new FlexPrintJob();
    if (printJob.start())
    //add the group
    var group:HGroup = new HGroup();  
    //set the height
    group.height = printJob.pageHeight;
    //set the width
    group.width = printJob.pageWidth;  
    //declare the text
    var textA:Text = new Text();
    //set the width to adjust with printer
    textA.percentWidth = 100;
    //set the text as html
    textA.text = textArea.text; 
    //add to the group 
    group.addElement(textA); 
    //add group to the screen
    addElement(group);
    //send job to printer
    printJob.addObject(group);
    printJob.send();
    removeElement(group);
    Problems:
    1. Only one page is printed.
    2. No formatting.
    Help required...
    Thanks in advance.

    Thanks for the reply.
    Can you please elaborate as I am not able to understand "how to adjust the text and call addobject for each page".
    It will be helpful if you can give me an example.
    Thanks again

  • TextArea insert problem

    Hi I am reading a file and adding it to a text area. I then want to move the cursor to a position in the textarea, and click a button to add text. The text I want to add should be at the current cursor position, I have tried to set i = tArea1.getCaretPosition, then use tArea1.insert("Blah Blah Blah", i), but the text gets added at the end of the current data
    Help........
    KPJ

    works fine for me here.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.border.BevelBorder;
    public class Test extends JFrame{
         DataField inputField, outputField;
         Container cont;
         public Test() {
              this.setBackground(Color.black);
              this.setSize(500,500);
              inputField = new DataField("enter a word or phrase", true);
              outputField=new DataField("below are the results", true);
              inputField.tf.addKeyListener(new KeyAdapter(){
                       public void keyPressed(KeyEvent e){
                            if (e.getKeyCode()==KeyEvent.VK_ENTER){
                                 e.consume();
                                 outputField.tf.insert(inputField.tf.getText(),outputField.tf.getCaretPosition()); //tf is the TextArea in the DataField
                                                                 //this is where text is inserted.
              cont=this.getContentPane();
              cont.setLayout(new BorderLayout());
              cont.add(inputField, "North");
              cont.add(outputField, "Center");
              this.setVisible(true);
         public static void main(String[] args){
              new Test();
    class DataField extends JPanel{
         JTextArea tf;
         JLabel label;
         public DataField(String string, boolean editable){
              super();
              label=new JLabel(string);
              label.setOpaque(true);
              label.setForeground(Color.lightGray);
              label.setBackground(Color.blue);
              tf=new JTextArea();
              tf.setBackground(Color.white);
              tf.setForeground(Color.black);
              tf.setEditable(editable);
              this.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.blue, Color.blue) );
              this.setBackground(Color.white);
              this.setLayout(new BorderLayout());
              this.add(label,"North");
              this.add(tf,"Center");
         public String get(){
              return tf.getText();
         public void set(String string){
              tf.setText(string);
    }

  • Textarea size problem on SharedWhiteBoard

    i have a problem with the SharedWhiteBoard when i'm typing really long text entries with the text tool.  when i commit the text, the text area overruns the bounds of the whiteboard and is clipped on either side.  i realize that the whiteboard component is still under development so perhaps this is a bug that hasn't been addressed yet.  are there any properties to set on SharedWhiteBoard to ensure that the text area is sized to stay within the bounds of the whiteboard?
    i've attached a screenshot to illustrate the issue.  i've also looked at WBShapeBase::sizeTA() but extending it to fix isn't practical.
    thanks
    adam

    Make sure you are using POST rather than GET to submit your form.
    i.e <form method="post">
    There is a limit to the amount of data you can submit when using get.

  • Linking Editing TextArea with Button Handler

    Java newbie here,i am trying to create a program to display a keyboard on screen and display the the letter in a text area when the character letter is pressed. And the complete sentence when return is pressed.
    I have the GUI up, the problem is the letters are dispayed in a JOptionPane and i want them to be written to the TextArea.
    Any help would be appreaciated
    Here is the code in full so far.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    * Alphabet is a program that will display a text pad and 27 buttons of the 25
    * Letters of the Alphabet and display them when pressed and display all buttons
    * when Return button is pressed..
    * version (V 0.1)
    public class Alphabet extends JFrame
        private JPanel buttonPanel  ;
        private JButton buttons[];
        private JButton SpaceButton;
        private JButton ReturnButton;
        //setup GUI
        public Alphabet()
        super("Alphabet");
        //get content pane
        Container container = getContentPane();
        //create button array
        buttons = new JButton[122];
        //intialize buttons
        SpaceButton = new JButton ("Space");
        ReturnButton = new JButton ("Return");
        //setup panel and set its layout
        buttonPanel = new JPanel();
        buttonPanel.setLayout(new GridLayout (7,buttons.length));
        //create text area
        JTextArea TextArea = new JTextArea ();
       TextArea.setEditable(false);
       container.add(TextArea, BorderLayout.CENTER);
       // set a nice titled border around the TextArea
        TextArea.setBorder(
          BorderFactory.createTitledBorder("Your Text is Displayed Here"));
      //create and add buttons
        for (int count = 96; count <buttons.length; count++ ) {
        buttons[count] = new JButton( ""+ (char)(count +1 ));
        buttonPanel.add(buttons [count]);
        ButtonHandler handler = new ButtonHandler();
        buttons[count].addActionListener(handler);
        buttonPanel.add(SpaceButton);
       buttonPanel.add(ReturnButton);
       ReturnButton.setToolTipText( "Press to Display Sentence" ); 
         container.add(buttonPanel, BorderLayout.SOUTH);
        // set a nice titled border around the ButtonPanel
        buttonPanel.setBorder(
          BorderFactory.createTitledBorder("Click inside this Panel"));
            // create an instance of inner class ButtonHandler
              // to use for button event handling              
              ButtonHandler handler = new ButtonHandler(); 
              ReturnButton.addActionListener(handler);
            setSize (625,550);
            setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
        Alphabet application = new Alphabet();
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
         private class ButtonHandler implements ActionListener {
              // handle button event
             public void actionPerformed( ActionEvent event )
                 JOptionPane.showMessageDialog( Alphabet.this,
                    "You pressed: " + event.getActionCommand() );
    }//END CLASS ALPHABET

    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class Alphabet extends JFrame
    private JPanel buttonPanel ;
    private JButton buttons[];
    private JButton SpaceButton;
    private JButton ReturnButton;
    JTextArea TextArea;
    String str="";String stt="";
    //setup GUI
    public Alphabet()
    super("Alphabet");
    //get content pane
    Container container = getContentPane();
    //create button array
    buttons = new JButton[122];
    //intialize buttons
    SpaceButton = new JButton ("Space");
    ReturnButton = new JButton ("Return");
    //setup panel and set its layout
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout (7,buttons.length));
    //create text area
    TextArea = new JTextArea ();
    TextArea.setEditable(false);
    container.add(TextArea, BorderLayout.CENTER);
    // set a nice titled border around the TextArea
    TextArea.setBorder(
    BorderFactory.createTitledBorder("Your Text is Displayed Here"));
    //create and add buttons
    for (int count = 96; count <buttons.length; count++ ) {
    buttons[count] = new JButton( ""+ (char)(count +1 ));
    buttonPanel.add(buttons [count]);
    ButtonHandler handler = new ButtonHandler();
    buttons[count].addActionListener(handler);
    buttonPanel.add(SpaceButton);
    buttonPanel.add(ReturnButton);
    ReturnButton.setToolTipText( "Press to Display Sentence" );
    container.add(buttonPanel, BorderLayout.SOUTH);
    // set a nice titled border around the ButtonPanel
    buttonPanel.setBorder(
    BorderFactory.createTitledBorder("Click inside this Panel"));
    // create an instance of inner class ButtonHandler
    // to use for button event handling
    ButtonHandler handler = new ButtonHandler();
    ReturnButton.addActionListener(handler);
    SpaceButton.addActionListener(handler);
    setSize (625,550);
    setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
    Alphabet application = new Alphabet();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
    private class ButtonHandler implements ActionListener {
    // handle button event
    public void actionPerformed( ActionEvent event )
              if((event.getActionCommand()).equals("Space")){
                   TextArea.setText(event.getActionCommand());
                   str+=" ";
                   //TextArea.append(" ");
              else if((event.getActionCommand()).equals("Return")){
                   stt+=str;
                   stt+="\n";
                   str="";
                   TextArea.setText(stt);
                   //TextArea.append(str);
                   //TextArea.append("\n");
              else {
                   TextArea.setText(event.getActionCommand());
                   str+=event.getActionCommand();
                   //TextArea.append(event.getActionCommand());
    }//END CLASS ALPHABET
    Ok?

  • Submit buttons stop working with large textarea

    I am using a PL/SQL portlet to display a form that has a large
    text box, using <TEXTAREA></TEXTAREA>, and two submit buttons,
    one for cancel and one for save. The database can accept 2000
    characters but when I fill the text box up beyond around 1400
    characters the buttons stop working.
    You just click away as if no code is behind them. Delete some
    text and they work again! The sizes that cause this seem to vary.
    If it helps I can paste the code in here, but didn't want to yet
    as it will clutter this message.
    Thanks,
    Chris.

    Got there in the end, but not sure if this is a bug or not so
    here is the answer just in case someone else makes the same
    mistake in the future:
    I was using some java script that required a form to have the
    name attribute set. I could not do this with HTP.FORMOPEN so
    changed HTP.FORMOPEN(curl=>'x.y.z'); to HTP.P('<FORM
    action="x.y.z">');
    Now I thought these two commands were exactly the same and most
    of the time they do seem to be, but the problem above goes away
    if using formopen.
    Bizzare!

  • TextArea sizing question

    hi,
    i have a TextArea. when i try to set its size it does not work before the window is shown.
    after the window is shown there is no problem with the setSize.
    any idea why?
    import java.awt.*;
    import java.awt.event.*;
    public class Components extends CloseableFrame
         TextArea textArea = null;
         public static void main(String[] args)
              Components f = new Components();
              f.setBounds(100, 100, 340, 300);
              f.setVisible(true);
         public Components()
              super("Components");
              setLayout(new java.awt.FlowLayout(
                   java.awt.FlowLayout.CENTER, 20, 10));
              textArea = new TextArea("my text", 20, 40, TextArea.SCROLLBARS_VERTICAL_ONLY);
              textArea.setForeground(Color.red);
              add(textArea);
              textArea.setSize(10, 10); // <<=== NOW WORKING !!!!!!
              Button btn = new Button("button");
              add(btn);
              btn.addActionListener(
                   new ActionListener() {
                        double sizeFactor = 0.5;
                        public void actionPerformed(ActionEvent e) {
                             Dimension size = textArea.getSize();
                             size.width = (int) (size.width * sizeFactor);
                             size.height = (int) (size.height * sizeFactor);
                             textArea.setSize(size); // <== WORKING !!!
                             if (sizeFactor == 0.5)
                                  sizeFactor = 2;
                             else
                                  sizeFactor = 0.5;
    }

    When you call setSize or pack the layout manager collects the preferred sizes of the components and lays them out. Until then it doesn't have the information available to give you.

  • Cfdocument with textarea auto Height

    Hi All,
    I successfully display the content but let the textarea auto
    detect my content lengh, so auto height, not fix rows. Below is the
    coding:
    But the problem is if i put cfdocument tags, then the pdf
    just display rows 2, not auto height.
    I tried cfhttp, cannot also.
    Any idea on this
    Thanks

    Hi
    In the end, I found out that that code only worked if the page had only one textarea (not my case :-/ ). So I decided to write myself a simpler (though not so bright) solution:
    Resizes vertically a textarea based on the size of the text it contains.
    NB: Works best with monospaced fonts
    function textarea_autoheight(textarea) {
      var c = 0;
      var r = 2;  // (*) IE does not seem to work well with
                  // textarea.rows so we need one more empty line at the end
      var t = textarea.value;
      for(var i=0; i<t.length; i++) {
        if (t.substr(i,1) == '\n') {
           c = 0;
          r++;
        else {
          c++;
          if(c >= textarea.cols) { c=0; r++;}
      textarea.rows = r;
    Resizes and binds a textarea (or all textareas in the page if the parameter is null)
    to the autoheight function above, so they get automatically resized as user enters text
    function textarea_activate_autoheight(textarea) {
      if(textarea != null) {
        g_textarea_autoheight(textarea);
        textarea.onkeyup = function() {g_textarea_autoheight(textarea);};
      else {
        var ta_list = document.getElementsByTagName('textarea');
        for(var i=0; i < ta_list.length; i++) g_textarea_activate_autoheight(ta_list);
    To use it, just add onload="textarea_activate_autoheight();" to activate it for all the textareas in the page. It seems to work well...
    If anyone knows how to fix the bug (*) above, please let me know!
    Luis

  • Want textarea to be displayed on the image

    Hello,
    I am stuck up with a problem,
    I have a JPaaplet which displays an image,
    and i want a textarea to appear whereever i click on the image.
    and i dono how to get this.
    it would be kindful if anyone could help me out with this. It is very urgent n i need to do it today itself
    Regards
    Sanam

    Hello,
    once again thanks for ur reply,
    ur code works fine but when i try to implement it in mine it is not working, is it becoz u have used label
    n i am using buffered image.
    iam really stuck up with this. plzzzzzzzzzzzz help . this is the code i have written there is 1 main class (zoominApplet1) it has the main mtd .
    1 more class(AppletZoomPanel) which basically performs zoomin n zoom out operation,
    1 more calss(ZoomAction) which has buutons n operations performed on them.
    now when i click on Auto Fit button i want the image to be resized to screen size.
    could u plz tell what is the mistake n how to do it.
    n i did not understand the 1st line of ur previous mail.
    actually i am new this forum so i dono abt those duke dollars
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    //ZoominApplet1 class
    public class ZoominApplet1 extends JApplet
         public static JFrame f;
         public AppletZoomPanel zoomPanel;
         public static Container cp;
         public BufferedImage image;
         JTextArea textArea;
         public void init()
              zoomPanel = new AppletZoomPanel();
              ZoomAction action = new ZoomAction(zoomPanel);
              cp = getContentPane();
              cp.setLayout(new BorderLayout());
              //cp.setLayout(null);
              cp.add(action, "North");
              cp.add(new JScrollPane(zoomPanel));
              txtArea();
         public void txtArea()
              zoomPanel.addMouseListener(new MouseAdapter()
                   public void mousePressed(MouseEvent e)
                        textArea = new JTextArea();
                        textArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
                        zoomPanel.add(textArea);
                        textArea.setBounds(e.getX(), e.getY(), 100,50);
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        f.pack();
                        f.show();
         public static void main(String[] args)
              JApplet applet = new ZoominApplet1();
              f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.getContentPane().add(applet);
              f.setSize(300,300);
              //f.setLocation(100,100);
              applet.init();
              f.setVisible(true);
    //AppletZoompanel class
    class AppletZoomPanel extends JPanel
         public BufferedImage image;
              double scale, scaleInc;
         public boolean autofit = false;
         public AppletZoomPanel()
              loadImage();
              scale = 1.0;
              scaleInc = 0.01;
              setBackground(Color.white);
              //Set to null
              setLayout(null);
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D)g;
              g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BICUBIC);
              int w = getWidth();
              int h = getHeight();
              System.out.println("width : " +w);
              System.out.println("height : " +h);
              double imageWidth = scale * image.getWidth();
              double imageHeight = scale * image.getHeight();
              double x = (w - imageWidth)/2;
              double y = (h - imageHeight)/2;
              AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
              xform.scale(scale, scale);
              g2.drawRenderedImage(image, xform);
         public Dimension getPreferredSize()
              Dimension d = new Dimension();
              d.width = (int)(scale * image.getWidth());
              d.height = (int)(scale * image.getHeight());
              return d;
         public void autoFit()
         public void setScale (int inc)
              scale += inc * scaleInc;
              revalidate();
              repaint();
         private void loadImage()
              String fileName = "sampleimg.jpg";
              try
              URL url = getClass().getResource(fileName);
              image = ImageIO.read(url);
              catch(MalformedURLException mue)
              System.out.println("url: " + mue.getMessage());
              catch(IOException ioe)
              System.out.println("read: " + ioe.getMessage());
    //ZoomAction Class
    class ZoomAction extends JPanel
         static final String[] fontStyleString = new String[] {"Font.PLAIN", "Font.ITALIC", "Font.BOLD", "Font.ITALIC+Font.BOLD"};
         static final int[] fontStyleInt = new int[] { Font.PLAIN ,  Font.ITALIC ,  Font.BOLD ,  Font.ITALIC+Font.BOLD };
         AppletZoomPanel zoomPanel;
         public ZoomAction(AppletZoomPanel azp)
              zoomPanel = azp;
              final JButton zoomIn = new JButton("zoom in"), zoomOut = new JButton("zoom out"), autoFit = new JButton("Auto Fit"), txtButton = new JButton("Text Area");
              JComboBox fontCombo;
              JComboBox styleCombo;
              String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
              //final JButton autoFit = new JButton("Auto Fit");
              /*add(new JButton(new AbstractAction("Auto Fit")
                   public void actionPerformed(ActionEvent e)
                        System.out.println("autofit");
                        zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
                        repaint();
    //                    ResizableImage resizableImage = new ResizableImage();
                        //resizeableImage.autoFit();
                        //resizableImage.setBounds(new Rectangle(zoomPanel.getSize()));
    //                    resizableImage.setBounds(new Rectangle(resizableImage.getPreferredSize()));
    //                    resizableImage.repaint();
         //               repaint();
              Vector visFonts = new Vector(fontNames.length);
              for(int i=0; i<fontNames.length; i++)
                   Font f = new Font(fontNames, Font.PLAIN, 12);
                   if (f.canDisplay('a'))
                        visFonts.add(fontNames[i]);
                   else
                        //System.out.println("No alphabetics in " + fontNames[i]);
              fontCombo = new JComboBox(visFonts);
              styleCombo = new JComboBox(fontStyleString);
              ActionListener l = new ActionListener()
                   int inc;
                   public void actionPerformed(ActionEvent e)
                        JButton button = (JButton)e.getSource();
                        if(button == zoomIn)
                        inc = 5;
                        if(button == zoomOut)
                        inc = -5;
                        zoomPanel.setScale(inc);
              zoomIn.addActionListener(l);
              zoomOut.addActionListener(l);
              ActionListener m = new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        JButton button = (JButton)e.getSource();
                        if(button == autoFit)
                             System.out.println("autofit");
                             //zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
                             //repaint();
                             ResizableImage     resizableImage = new ResizableImage();
                             resizableImage.repaint();
                             System.out.println("repaint");
                             //zoomPanel.setBounds(new Rectangle(zoomPanel.getSize()));
         //                    final AppletZoomPanel resizableImage = new ResizableImage(new                               ImageIcon(imageUrl).getImage());
                        if(button == txtButton)
                                  //AppletZoomPanel azp1 = new AppletZoomPanel();
                                  //azp1.setTextArea();
                                  //ZoominApplet1 za1 = new ZoominApplet1();
                             //za1.txtArea();
              autoFit.addActionListener(m);
              txtButton.addActionListener(m);
              add(txtButton);
              add(zoomIn);
              add(zoomOut);
              add(autoFit);
              add(fontCombo);
              add(styleCombo);
         public Dimension getPreferredSize()
              return new Dimension(ap.image.getWidth(null), ap.image.getHeight(null));
         AppletZoomPanel ap = new AppletZoomPanel();
         protected void paintComponent(Graphics g)
              Graphics2D g2D = (Graphics2D)g;
              System.out.println("grahics :" +g2D);
              Dimension dim = getSize();
              System.out.println("dim : " +dim);
              int imageWidth = ap.image.getWidth(null);
              System.out.println("width : " +imageWidth);
              int imageHeight = ap.image.getHeight(null);
              System.out.println("height : " +imageHeight);
              double scaleX = (double)dim.width / (double)imageWidth;
              System.out.println("scalex : " +scaleX);
              double scaleY = (double)dim.height / (double)imageHeight;
              System.out.println("scaley : " +scaleY);
              g2D.drawImage(ap.image, AffineTransform.getScaleInstance(scaleX, scaleY), null);
    class ResizableImage extends JComponent
         AppletZoomPanel ap = new AppletZoomPanel();
         public Dimension getPreferredSize()
              return new Dimension(ap.image.getWidth(null), ap.image.getHeight(null));
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              Graphics2D g2D = (Graphics2D)g;
              System.out.println("grahics :" +g2D);
              Dimension dim = getSize();
              System.out.println("dim : " +dim);
              int imageWidth = ap.image.getWidth(null);
              System.out.println("width : " +imageWidth);
              int imageHeight = ap.image.getHeight(null);
              System.out.println("height : " +imageHeight);
              double scaleX = (double)dim.width / (double)imageWidth;
              System.out.println("scalex : " +scaleX);
              double scaleY = (double)dim.height / (double)imageHeight;
              System.out.println("scaley : " +scaleY);
              g2D.drawImage(ap.image, AffineTransform.getScaleInstance(scaleX, scaleY), null);

  • Table with a textArea editor doesn't stop editing

    I need to have a table with TextArea as editor (to show the information) but it must be changed through a Dialog and return to the render (also a textArea)
    The problem is when after modify the information with the editor I call fireEditingStopped(); and it doesn't return to the render it remains in editor so I can modify the text and when I change of cell It returns to the text put by the editor. I need that the user can't change the text showed in the textArea only be modified through the Dialog.
    In the next code I isolated the problem, so the Editor change the original text with "NEW VALUE" simulating the action of Dialog (which is not included).
    Thanks a lot and thanks for the patience for my bad English.
    public class TableWithTextArea extends javax.swing.JFrame {
        public TableWithTextArea() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new java.awt.FlowLayout());
            this.getContentPane().add(new MyTabla());
            pack();
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TableWithTextArea().setVisible(true);
        class MyTabla extends javax.swing.JTable {
            public MyTabla() {
                this.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
                this.setModel(new javax.swing.table.DefaultTableModel(
                        new Object [][] {
                            {"A HOLA MUNDO", "B HOLA MUNDO", "C HOLA MUNDO", "D HOLA MUNDO"},
                            {"E HOLA MUNDO", "F HOLA MUNDO", "G HOLA MUNDO", "H HOLA MUNDO"},
                            {"I HOLA MUNDO", "J HOLA MUNDO", "K HOLA MUNDO", "L HOLA MUNDO"},
                            {"M HOLA MUNDO", "N HOLA MUNDO", "O HOLA MUNDO", "P HOLA MUNDO"}
                        new String [] {
                            "Title 1", "Title 2", "Title 3", "Title 4"
            public javax.swing.table.TableCellEditor getCellEditor(int row, int column) {
                    return new StringEditor(this);
            //CLASS StringEditor
            class StringEditor extends javax.swing.AbstractCellEditor
                                     implements javax.swing.table.TableCellEditor {
                private final static long serialVersionUID = 10092;
                javax.swing.JTable tabla;
                javax.swing.JTextArea editTextArea;
                String theValue = "";
                public StringEditor(MyTabla tabla) {
                    super();
                    this.tabla = tabla;
                    editTextArea = new javax.swing.JTextArea();
                    editTextArea.setLineWrap(true);
                    editTextArea.setWrapStyleWord(true);
                    editTextArea.setAutoscrolls(true);
                @Override
                public Object getCellEditorValue() {
                    return theValue;
                @Override
                public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) {
                    editTextArea.setLineWrap(true);
                    theValue = "NEW VALUE";
                    editTextArea.setText(this.theValue);
                    fireEditingStopped(); //IT'S NOT WORKING
                    return editTextArea;
    }

    Thanks a lot.
    It does just what I need, I read it before but I thought that it wasn't the solution to my problem.
    I'll study your code to understand what I did wrong.

  • Add scroll bars to TextArea - how?

    I have an application which reads user input to a text file and then on click of JButDisplay reads the contents of the file to a TextArea.
    Problem is I can't seem to get scroll bars onto the TextArea, I tried using JScrollPane,
    but had no luck (I'm using gridBagLayout)
    Could someone please advise me how to add scrollbars to this component?
    TADisplay2 = new JTextArea(10,20);     
                   c.ipadx = 12;
                   c.ipady = 12;
                        c.gridx = 2;
                        c.gridy=18;
                        c.gridwidth = 2;   //2 columns wide
                        c.gridheight = 4;
                             gridbag.setConstraints(TADisplay2, c);
                             contentPane.add(TADisplay2);

    1) Create scrollPanel
    2) Make it fill your content pane (or whatever area you wish to cover)
    3) Add your textArea to the scrollpanel

  • Read from text file, display in textarea

    java newbie here - I'm trying to write a chat program that checks a text file every 1 second for new text, and then writes that text to a textArea. I've got the thread setup and running, and it checks and text file for new text - all that works and prints to system console - but I have no idea how to print that text to a textArea.
    I've tried textArea.append, but it seems this only works on the initial run - if I put it in the thread, it won't work. I can make textArea.append work if its in an ActionEvent - but how would I make an ActionEvent run only when my script detects new text from my text file?
    Any ideas on how to do this are appreciated.
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I've tried textArea.append, but it seems this only works on the initial
    run - if I put it in the thread, it won't work. I can make textArea.append
    work if its in an ActionEvent - but how would I make an ActionEvent
    run only when my script detects new text from my text file? ?
    It doesn't matter if you call the textArea.append() when the ActionEvent is triggered or if you call textArea.append() directly from a thread or any other object, the text will be append to te text area. What could have happen is you somehow lost the reference pointing to the textArea that you add to your user interface.
    example:
    JTextArea txtArea = blah..blah..blah
    MyThread t = new myThread(txtArea);
    class MyThread extends Thread{
        private JTextArea txtArea;
        public MyThread(Thread textArea){
            this.textArea = textArea;
        public void run(){
            textArea = new JTextArea(); // opps..you lost the reference to the textArea in the main gui...what you have done is created a new JTextArea object and point to tat..and this textarea object is not visible.
    }

  • How can I hide the scroll bar in TextArea?

    How can I hide the scroll bar in TextArea?

    Hi. To remove the horizontal scrollbar you can do this:
    textArea.setWrapText(true);
    To remove the vertical scrollbar you can do this:
    ScrollBar scrollBarv = (ScrollBar)ta.lookup(".scroll-bar:vertical");
    scrollBarv.setDisable(true);  and set the opacity to 0 in the css file:
    //css file
    .text-area .scroll-bar:vertical:disabled {
        -fx-opacity: 0;
    }Here is an example:
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ContextMenu;
    import javafx.scene.control.MenuItem;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.control.TextArea;
    import javafx.scene.input.ContextMenuEvent;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    public class TextAreaSample extends Application {
        @Override
        public void start(Stage primaryStage) {
        final TextArea textArea = new TextArea();
            textArea.setWrapText(true);
            StackPane root = new StackPane();
            root.getChildren().add(textArea);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setScene(scene);
            primaryStage.show();
            scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
            ScrollBar scrollBarv = (ScrollBar)textArea.lookup(".scroll-bar:vertical");
            scrollBarv.setDisable(true);
        public static void main(String[] args) {
            launch(args);
    }

Maybe you are looking for

  • Super Newbie trying to stream external video to FMS

    Okay, I'm totally new and in the absolute dark here.  I have installed FMS on a server in the TV station in which I work.  I am trying to figure out how to stream video from Adobe Flash Media Live Encoder on an outside computer, back into the FMS at

  • IDVD 5 and LOSS of older themes

    I've seen some things floating around here about lost themes. Have tried most of them without success. My issue: I upgraded to Tiger. Then decided to wipe the drive and start over. Copied Users data over to second drive and brought back across after

  • Which interface are gig on the 5510

    I have 2 asa 5510 that I upgraded to security plus license. Im suppose to have 3 10/100 and 2 10/100/1000 interfaces. which one are the gig interfaces. not of the ethernet or management can be set faster then 100Mbps

  • WorkFlow Error -Strategy RR_MANAGER did not determine any approver

    Dear ,my expert: I work in SRM7.0 .SRM extended classic scenario.I want to use the contract one-step approve workflow and active it . one-step approve :/SAPSRM/C_CT_600_001_SP04   And I set the manager in the ORG. Plan After I releasing one contract

  • PDF books added in iTunes 11.1.3 shows up in Music Albums tab [Probably a bug]

    iTunes 11.1.3 still allows you to add PDF books to library and the imported books show up in the albums view under the music selection. Seems weird, as books tab was removed from itunes. Importing 10 books results in creation of an album tab which is