Results 1 to 2 of 2
  1. #1
    kkoo is offline Member
    Join Date
    Feb 2014
    Rep Power

    Default How to change the location of a JTextArea at run-time?

    I am using Swing, I have a JPanel and in it there is a JTextArea and a JButton. I want the JTextArea to move when the button is clicked on. I'm Not really sure how to do the action listener for the button. at the moment the JTextArea only moves once when the button is clicked on, but i want it to move every time the button is clicked on.

    this is what i have so far:

    moveButton = new JButton("MOVE");
    moveButton.setBounds(20, 140, 70, 40);

    text = new JTextArea("hello");
    text.setBounds(x, 50, 40, 20);


    In the actionPerformed method this is what it does:

    text.setBounds(x + 50, 50, 40, 20);

    any help is greatly appreciated.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: How to change the location of a JTextArea at run-time?

    What layout are you using? Can you post an SSCCE instead of a disconnected snippet?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Replies: 6
    Last Post: 06-19-2013, 05:36 PM
  2. How to change the location of buttons on a JFrame???
    By nithyajann in forum AWT / Swing
    Replies: 1
    Last Post: 03-18-2012, 12:57 PM
  3. Monitoring JTextArea for change and then changing it.
    By valdeEdius in forum AWT / Swing
    Replies: 5
    Last Post: 03-18-2012, 04:09 AM
  4. Change appearance of lines in a JTextArea
    By blackbird in forum AWT / Swing
    Replies: 11
    Last Post: 07-11-2011, 05:58 PM
  5. How to Change MySQL Database Location
    By sayan751 in forum JDBC
    Replies: 3
    Last Post: 03-19-2009, 03:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts