Results 1 to 4 of 4

Thread: Text area problem

  1. #1
    Join Date
    Jul 2009
    Posts
    140

    Text area problem

    Hi
    I have created some java console based programs, now I want to make a GUI that has a JTextArea inside a JScrollPane inside a JPanel. When I didn't have the JPanel it would always make the JTextArea the size of the window, but when I have them inside the JPanel, the JTextArea will stay the preferred size and the JScrollPane wouldn't work. I want to make it so I can have the JPanel and make it so that the JScrollPane is the same size as the window, and if there is too much text, the scrollbars will appear. Please help, thanks.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Text area problem

    Hi
    I think the problem is with the layout manage. Are you using any layout manage here, and if so which one. JPanel by default uses FlowLayout which might not be the best fit for your purposes. Perhaps a Borderlayout is what you want, and then you can add the JScrollPane to the JPanel in the BorderLayout.CENTER position. It would be better if you post your code. so that I can check it and if possible can solve it.

  3. #3
    Join Date
    Jul 2009
    Posts
    140

    Re: Text area problem

    Hi,
    Thanks for replying. I am posting my code below, go through it, if any solution the reply me back.
    Code:
    public class Resize extends JFrame 
    {
    Jpal pa = new Jpal(false);
    JScrollpa scrollpa;
    JtxArea tx = new JtxArea(50, 80);
    JTabbedpa tabbedpa = new JTabbedpa();
    
    public Resize()
    {
    scrollpa = new JScrollpa(tx);
    pa.add(scrollpa, BorderLayout.CENTER);
    tabbedpa.addTab("Resize", null, pa, "");
    add(tabbedpa);
    }
    
    public static void main( String args[] )
          {
             final Resize window = new Resize();
             window.setSize( 1680, 1050 );
             window.setVisible( true );
          }
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Text area problem

    Hi
    I am posting the code. I have tried it, you see if it suits your needs.
    Code:
    public class Resize extends JFrame {
       Jpnl pn = new Jpnl(false);
       JScrollpn scrollpn;
       JtxArea tx = new JtxArea(50, 80);
       JTabbedpn tabbedpn = new JTabbedpn();
    
       public Resize() {
          pn.setLayout(new BorderLayout()); // set the Jpnl's layout to BorderLayout
          
          scrollpn = new JScrollpn(tx);
          pn.add(scrollpn, BorderLayout.CENTER);
          tabbedpn.addTab("Resize", null, pn, "");
          add(tabbedpn);
       }
    
       public static void main(String args[]) {
          final Resize window = new Resize();
          window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          window.setSize(1680, 1050);
          window.setVisible(true);
       }
    }

Similar Threads

  1. using javascript how to clear text area?
    By talia in forum Software Development
    Replies: 4
    Last Post: 03-02-2014, 04:26 PM
  2. Bug found in Opera 11.60 that makes search in text area useless.
    By Sib Bachchan in forum Technology & Internet
    Replies: 3
    Last Post: 26-02-2012, 12:28 PM
  3. Resize any text area in Firefox
    By Computer_Freak in forum Tips & Tweaks
    Replies: 4
    Last Post: 19-11-2011, 04:04 AM
  4. How to recover lost text from text area in Google Chrome?
    By Corwinn in forum Technology & Internet
    Replies: 5
    Last Post: 10-03-2010, 12:56 PM
  5. how to do highlight text area in html
    By Shanbaag in forum Software Development
    Replies: 3
    Last Post: 30-07-2009, 02:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,695,146.27428 seconds with 17 queries