I'm having trouble with making my JPanel look right. I am not very experienced with building GUIs yet. I've tried everything I could and now I need some major help. The JFrame is very simple looking. I got it as close as i could and then threw a screenshot in paint to modify it to how I want it to look. Can someone help me? I just want it to look very similar to the screen shot. But when the program starts, the green panel will be opaque, then after you click the button, depending on the result of the if-then statement I will write, it will either turn RED or GREEN. I know how to do that but I just need the actual layout corrected. Ignore the "fake" button i created. I was experimenting and it was the only way I could get the colored pane to show up on the bottom. I think my grid is just not formatted right.
probably not the simplest way to do it (and you'll need to test what you want done if the frame is dragged wider or leaner)
(if you need the button/textfield to be taller, just set their preferredSize.height)
GridLayout is a good layout manager if you want to layout components in a grid where every component is the same size. But the image you have provided suggests this is not what you want to do - you don't want a grid style layout and the components are not the same size.
There are lots of other Layout Managers available, some could handle this is one go (ie GridBagLayout) others would need to be used in combination (eg FlowLayout for the top line components, GridLayout for the panel holding the top line and the second line component and BorderLayout for the panel holding the upper components (NORTH) and the coloured area component (CENTER)).
Joined: Feb 24, 2012
Thank you Michael! That is exactly how I want it to look. Thanks for the help.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com