Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: JFrame resolution?

I made a program using several JFrames on a Mac, and the resolution was okay, everything fit the screen properly. But when I run the program on my PC the JFrames are way too large and go right off the screen.

My question is: Is it possible to set the universal resolution on a JFrame so that all the components are drawn a little smaller? I would rather do that then go through the entire program and resize every component manually.

like image 859
Blackvein Avatar asked May 27 '26 18:05

Blackvein


1 Answers

I made a program using several JFrames

wrong use CardLayout instead, only if is there real reason use JDialog or JOptionPane with parent and (JDialog) maybe with setModal(true) to the single JFrame

But when I run the program on my PC the JFrames are way too large and go right off the screen

  • are you using AbsoluteLayout

  • is your PC somehow specific

  • every Native OS returns different (for example there you cann't find out two containers with the same pixels ratio on the screen) Font and default Size for JComponents

Is it possible to set the universal resolution on a JFrame so that all the components are drawn a little smaller?

use proper LayoutManager, sure not easy job, required real effort

I would rather do that then go through the entire program and resize every component manually.

use proper LayoutManager,

  • for better help sooner edit your question with SSCCE demonstrated your issue with different screen size betweens PC's or platforms
like image 106
mKorbel Avatar answered May 30 '26 08:05

mKorbel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!