• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need some help with JTextArea possition and size  RSS feed

 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, I need to make a simple applet, but I'm stuck with something. This is how my applet should look:



And this is how that part looks in my applet:



What I've done until now is create one JPanel which includes two other JPanels.. The first one contains only the JTextArea you can see, and the other one includes the other elements.
I just need to make the JTextArea taller, like in the example, so everything comes into place...
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to show us the layout code you are using for that panel.
Generally to get one component to fill as much of the area as possible you can use a BorderLayout in the root JPanel and add the JTextArea to the CENTER then add all the other components to their own JPanel which you add to the SOUTH.

I'll move this quetion to the Swing forum where you may get more help.
 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for messing the category.

My curent code is made from one main JPanel, which contains 3 other JPanels (for each part of the applet, as in the picture).

Then my 2nd JPanel (the on in the 2nd picture, which is declared in this way: JPanel tiket=new JPanel(new GridLayout(2,1)); " ) is made from two other JPanels, one containing only the JTextArea, and the other one the other elements. I tried putting the JTextArea to CENTER but it doesn't work... I also tried making the first JPanel (the one that ONLY contains the JTextArea) as CENTER, and the other one as SOUTH, still doesn't work.

Any ideas?
 
Paul Clapham
Sheriff
Posts: 22378
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, a GridLayout divides the panel into equal-sized areas. It sounds like that isn't what you want. In that case you shouldn't use a GridLayout. Perhaps you should consider Tony's advice and use a BorderLayout? I think that should help you to get your layout the way you want it.
 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I tried declaring my JPanel like this:

This is the JPanel that is in the 2nd picture...


Now inside this one, I add to other JPanels:



Still shows the same.... What am I doing wrong this time? /:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!