Results 1 to 4 of 4
  1. #1
    gancio is offline Member
    Join Date
    Aug 2009
    Posts
    11
    Rep Power
    0

    Default JtextArea and JSpliPane

    I have a problem.
    I've put a JScrollPane with a JTextArea in the bottom part of a JSplitPane but when I use the "OneTouchExpandable button" to expand the bottom part my JTextArea don't resize.
    Instead the top Panel works well and resize correctly.

    here the SplitPane code:

    Java Code:
    splitPane.setOneTouchExpandable(true);
            splitPane.setResizeWeight(0.5);
            splitPane.setDividerLocation(0.5);
            splitPane.setContinuousLayout(true);
    and other usefull code I used:

    Java Code:
    displayArea = new JTextArea();
            displayArea.setEditable(false);
            displayArea.setFont(LOG_FONT);
            displayArea.setLineWrap(true);
            JScrollPane areaScrollPane = new JScrollPane(displayArea);
            areaScrollPane.setPreferredSize(new Dimension(500, 150));
            areaScrollPane.setMinimumSize(new Dimension(100, 50));
            areaScrollPane.setBorder(BorderFactory.createCompoundBorder
                    (BorderFactory.createTitledBorder("Log Text"),
                    BorderFactory.createMatteBorder(2,2,2,2,Color.GREEN)));
            displayPanel.add(areaScrollPane);
    What should I do to make the bottom JTextArea to resize correctly?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Try not setting a preferredSize for the JScrollPane.

    db

  3. #3
    gancio is offline Member
    Join Date
    Aug 2009
    Posts
    11
    Rep Power
    0

    Default

    I tried.. now it resize correctly but it's too small :confused:
    Setting directly the size (setSize) of the Jtextarea it works partially cause at the beginning it displays only 1 row. :confused:
    Last edited by gancio; 08-26-2009 at 09:45 AM.

  4. #4
    gancio is offline Member
    Join Date
    Aug 2009
    Posts
    11
    Rep Power
    0

    Default

    I made a stupid error
    Java Code:
    JSplitPane splitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                                  sudoPanel,[B]displayPanel[/B]);
    Now it's working (also with PreferredSize) and new code is;
    Java Code:
    //displayPanel.add(areaScrollPane); //useless
    JSplitPane splitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                                  sudoPanel,[B]areaScrollPane[/B]);
    Last edited by gancio; 08-26-2009 at 03:50 PM.

Similar Threads

  1. About JTEXTAREA
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 03-19-2009, 06:53 AM
  2. How to add a shortcut key from JTextArea
    By sukatoa in forum Advanced Java
    Replies: 2
    Last Post: 01-28-2008, 08:39 AM
  3. JTextArea
    By saytri in forum New To Java
    Replies: 0
    Last Post: 01-13-2008, 01:07 AM
  4. Jtextarea and scroll
    By ziniestro in forum AWT / Swing
    Replies: 2
    Last Post: 06-01-2007, 03:59 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
  •