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

    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.setName("move");
    moveButton.setBounds(20, 140, 70, 40);

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

    panel.add(moveButton);
    panel.add(text);


    In the actionPerformed method this is what it does:

    text.setBounds(x + 50, 50, 40, 20);
    panel.add(text);
    text.setVisible(true);



    any help is greatly appreciated.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,969
    Rep Power
    8

    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 - Play indie games, learn from game tutorials and source code, upload your own games!

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, 11:57 AM
  3. Monitoring JTextArea for change and then changing it.
    By valdeEdius in forum AWT / Swing
    Replies: 5
    Last Post: 03-18-2012, 03: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, 02: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
  •