Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need some help please.  RSS feed

 
Kyle Ealy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm kind of new to creating serious Java applications. The problem I am having is with layout managers. I created a vertical box to make a form for logging in users. The box looks fine, however, the border layout makes my box components look funny(i.e too big, too wide) when the frame is re-sized. Flow layout looks fine, but I am unable to make the box re-size with the frame. Grid layout gives similar results to that of the border layout. Any help or suggestions would be greatly appreciated and I give my thanks in advance.
 
Amit N Chudasama
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to understand and use BoxLayout.

Have help here @ http://download.oracle.com/javase/tutorial/uiswing/layout/box.html
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kyle Ealy, welcome to Javaranch.

If you put your title like "Need some help please." it will be not clear to help you.

Could you post your code so far? So we will help you.
 
Kyle Ealy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really want to post this particular code. It was basically extending a JFrame, creating a textfield, password field, a JButton, and adding them to a JPanel or the frame. I have tried every Layout manager and I need help with fixing the components size so they do not re-size with the frame.

MY code is similar to this

public class Class extends JFrame{

JTextField jtextField = new JTextfield();
JPasswordField jpassWordField = new JPasswordField();
JButton jbutton = new JButton();

public Class(){
<---------- The problem is when I set a layout manager here I have trouble understanding the mechanics of fixing the size of components so that they do not change when I re-size the frame.
add(jtextfield);
add(jpassWordField);
add(jbutton);

}
}

Sorry for taking a bit to respond I was pretty busy.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I don't really want to post this particular code.

fair enough, we won't post the specific answer.

> MY code is similar to this

my answer is similar to nesting layout managers (extemely simple once you understand each LM's 'niceties')
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want to post your real code, you should at least post an SSCCE (click on it) that display the unwanted behaviour, and a proper description (possibly with images) of what the behaviour you do want. You should also read http://download.oracle.com/javase/tutorial/uiswing/layout/index.html as it explains quite a bit about layout managers.
 
Nijin puthiya purayil
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai kyle,
it will be help full if you use grouplayout instead of all other layouts....if you are not familiar with it try using gridbaglayout
wish you good luck...
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nijin puthiya purayil wrote:hai kyle,
it will be help full if you use grouplayout instead of all other layouts....if you are not familiar with it try using gridbaglayout
wish you good luck...

Are you trying to be funny? Even the designers of GroupLayout don't recommend its use for manual coding -- it was created with visual designers in mind -- and GridBagLayout is another advanced layout manager that requires some serious study and understanding to use effectively.

Kyle, we're waiting on that SSCCE, and accompanying it with a sketch of the desired layout wouldn't hurt.

edit @Nijin -- please use correct capitalization for Java classes and at the start of a sentence.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!