Results 1 to 6 of 6
  1. #1
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Post JTextArea resizing problem

    Hi everyone,

    the problem I am facing is that when I increase the number of rows in my jtextarea, the jtextfields in the panel are automatically resized with the same dimensions of the textarea.

    I've tried everything that I know.
    Could somebody help....?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What kind of layout are you using? Are you throwing everything on the same panel? Sometimes playing around with layouts and different configurations can help you solve GUI logic problems like this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,425
    Rep Power
    20

  4. #4
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Default

    I am using GridLayout.
    I have added different components on different panels, and then added the panels on a single panel.

    here is the code for panels

    private void createComponent()
    {
    this.createLabel();
    this.createTextField();
    this.createTextArea();
    this.createRadioButton();
    this.createComboBox();
    this.createButton();

    JPanel p1=new JPanel(new GridLayout(2,2,5,5));
    p1.add(l1);
    p1.add(t1);
    p1.add(blank1);
    p1.setBorder(BorderFactory.createEtchedBorder());

    JPanel p2=new JPanel(new GridLayout(1,2,5,5));
    p2.add(l2);
    p2.add(t2);
    JPanel p3=new JPanel(new GridLayout(1,3,5,5));
    p3.add(l3);
    p3.add(r1);
    p3.add(r2);
    JPanel p4=new JPanel(new GridLayout(2,1,5,5));
    p4.add(p2);
    p4.add(p3);
    p4.setBorder(BorderFactory.createEtchedBorder());

    JPanel p5=new JPanel(new GridLayout(2,2,5,5));
    p5.add(l4);
    p5.add(t3);
    p5.add(l5);
    p5.add(t4);
    p5.setBorder(BorderFactory.createEtchedBorder());

    JPanel p6=new JPanel(new GridLayout(2,2,5,5));
    p6.add(l6);
    p6.add(spane);
    p6.add(l7);
    p6.add(t5);
    p6.setBorder(BorderFactory.createEtchedBorder());

    JPanel p7=new JPanel(new GridLayout(2,2,5,5));
    p7.add(l8);
    p7.add(t6);
    p7.add(l9);
    p7.add(t7);
    p7.setBorder(BorderFactory.createEtchedBorder());

    JPanel p8=new JPanel(new GridLayout(2,3,5,5));
    p8.add(l10);
    p8.add(cb);
    p8.add(blank2);
    p8.add(l11);
    p8.add(t8);
    p8.add(b1);
    p8.setBorder(BorderFactory.createEtchedBorder());

    JPanel acc=new JPanel(new GridLayout(6,1,5,5));
    acc.add(p1);
    acc.add(p4);
    acc.add(p5);
    acc.add(p6);
    acc.add(p7);
    acc.add(p8);
    acc.setBorder(BorderFactory.createTitledBorder("Op en Account"));

    this.getContentPane().add(acc);
    }

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    To reiterate Darryl's suggestion: use an appropriate layout. GridLayout obviously doesn't work here for you. Also, use variable names that make sense. If you go back to this code in a week, you'll be doing what we're doing now: scratching your head trying to figure out just what p4 and all the other cryptic names mean. Also, if you're going to post code, post a small compilable program that we can run, not the uncompilable and uninterpretable code posted above.
    Last edited by Fubarable; 07-24-2011 at 03:00 PM.

  6. #6
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Default

    thank u so much to all of you.....

    I will try to change the layout...

Similar Threads

  1. JFrame resizing problem
    By Bluefox815 in forum AWT / Swing
    Replies: 7
    Last Post: 02-24-2011, 08:56 PM
  2. Basic Java GUI problem, JPanel not resizing.
    By Cemi in forum New To Java
    Replies: 10
    Last Post: 04-11-2010, 02:20 AM
  3. Problem resizing JPanel on window resize
    By Nyet in forum AWT / Swing
    Replies: 4
    Last Post: 11-27-2009, 04:13 AM
  4. Problem with JEditor Pane while resizing the frame
    By sidharth in forum SWT / JFace
    Replies: 5
    Last Post: 11-13-2009, 06:43 AM
  5. Problem in resizing JTable in netbeans
    By shahid0627 in forum NetBeans
    Replies: 1
    Last Post: 09-07-2009, 07:33 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
  •