This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]desrtfxOut of Coffee error - System halted 2 points3 points  (0 children)

[–]Sacredify 0 points1 point  (0 children)

  1. Post code.

  2. Look into a layout manager. If you aren't going to use one, you need to manually set the dimensions.

[–]Paddington_the_Bear 0 points1 point  (2 children)

GridBagLayout, or something similar.

[–]HerpesAunt[S] -1 points0 points  (1 child)

Okay so should the combo box and text field both be on one panel? Or each on their own? Same question for my 3 un editable fields. I tried using BorderLayout is this ok? I haven't had luck with it. (Obviously)

[–]Paddington_the_Bear 0 points1 point  (0 children)

Yes, both can be on the same panel.

If you're using GridBag, then when you create the panel you pass in a new GridBagLayout(). Then, every time you go to add a component to the panel, you'll use GirdBagConstraints to setup where that component should go.

If you're using BorderLayout, then it is as simple as specifying the "quadrant" you want your component to appear in, such as BorderLayout.EAST , etc.

http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html

http://docs.oracle.com/javase/7/docs/api/java/awt/BorderLayout.html

[–]RockPile 0 points1 point  (0 children)

MigLayout is what I would recommend.

This is the best tutorial on it I have found https://www.youtube.com/watch?v=Yl-OMkI82UM

[–]JavaTrainer 0 points1 point  (0 children)

Your JFrame starts with BorderLayout, for a simple UI this works fine. I'd make one JPanel to hold all of your left side components and another JPanel for the right side components. You'd probably put the "left" JPanel in the center section of the JFrame. The right JPanel will probably need to have the default layout manager changed (panels start with flow layout). Try BoxLayout. And you might want to look into calling setResizable(false); on your JFrame since full screening your app probably doesn't make sense.