Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Assign layout_width programmatically

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Assign layout_width programmatically

    I have created a Button programmatically but I have to set its layout_width. How can I do this?
    Wich paclages I have to import?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Assign layout_width programmatically

    Quote Originally Posted by ptia View Post
    I have created a Button programmatically but I have to set its layout_width. How can I do this?
    Wich paclages I have to import?
    You should define your problem in more exact terms. Can you provide an SSCCE that demonstrates what you have, and explain more regarding what you want?

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Assign layout_width programmatically

    First off all it's not a good idea setting layout programmatically.

    Button button = new Button(this);
    bt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams .WRAP_CONTENT));

  4. The Following User Says Thank You to alaindhaene For This Useful Post:

    ptia (December 16th, 2012)

Similar Threads

  1. Cannot assign requested address
    By frozen java in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 12th, 2012, 01:32 PM
  2. How to programmatically set combobox width?
    By stab in forum AWT / Java Swing
    Replies: 1
    Last Post: June 3rd, 2011, 04:59 PM
  3. Programmatically Creating Jars
    By aussiemcgr in forum Java Theory & Questions
    Replies: 8
    Last Post: October 6th, 2010, 12:51 PM
  4. [SOLVED] frame closing programmatically
    By nasi in forum AWT / Java Swing
    Replies: 9
    Last Post: May 10th, 2010, 04:43 AM
  5. Replies: 3
    Last Post: April 14th, 2010, 08:33 PM