Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Text area problem

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-11-2009
Member
 
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.

Reply With Quote
  #2  
Old 13-11-2009
Member
 
Join Date: May 2008
Posts: 2,289
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.
Reply With Quote
  #3  
Old 13-11-2009
Member
 
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 );
      }
}
Reply With Quote
  #4  
Old 13-11-2009
Member
 
Join Date: May 2008
Posts: 2,289
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);
   }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 12:40 PM.