Hi buddies!

I'm creating an application that will be used at different operating systems and, most likely, different display resolutions. My current display resolution is 1680x1050. I've tried using layouts to position components in the frame. So, I didn't define any sizes of components (did't use "setSize", "setBounds", setLocation"). However, if I need to update JPanel with some new components, then the size of my application sometimes becomes insufficient. It is logically, because all components have different default sizes. For instance, I've initially created JPanel with some buttons and labels; then I want to update JPanel with some JTree by the button click. In this case, some corners of JTree becomes invisible. I guess I was clear enough in my explanation.

So, the question is what is the best way to create applications for different
display resolutions? Maybe, I must set sizes of components with respect to display size? Or, maybe, there is some trick with layouts?

Any suggestions will be highly appreciated!. Thanks!

Recommended Answers

All 2 Replies

Please, suggest me something. Your professional feedback would help me very much!

You will need to decide upon a target minimum resolution and develop towards that.

GridBagLayout and appropriate use of scroll panes, tabbed panes, etc. will get you the rest of the way towards supporting various resolutions. GridBagLayout offers a lot of flexibility through anchoring, filling, and setting component weights to control how screen space is allocated to the components and where the components prefer to reside.

Subdivide your UI as needed into multiple sub-panels to help manage the complexity of smaller groups of related components. You can nest as many panels within panels as you need, so don't think you have to manage a whole lot of components with a single massive layout.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.