Is there any possibilities to scale the contents of the J Frame For Example : if im giving the initial setSize(800,1000) in which i placed the textfields,labels,buttons etc..as per the size 800,1000 the application looks good,suppose im maximizing the window of the Frame, automatically the textfields,labels,buttons are kept in the static way...how to scale it when the maximize is pressed the entire contents are cleanly arranged in good manner..kindly give me solution to solve this issue
Asked
Active
Viewed 144 times
1
-
2What's about LayoutManager? Read specs here: http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html – Sergiy Medvynskyy Feb 06 '13 at 20:05
-
i created a container called c in which i set with the contentpane() the layoutmanager setLayout(null) i gave – JAVA Beginner Feb 06 '13 at 20:10
-
1Sergiy is right -- the way to do this is with a layout manager (or quite a few layout managers). You will need to look them up, read about them, study, and practice, and then you can figure out how to do this with your app. Sorry, there is no "quick fix" for this, it's a more complicated problem than it seems. – arcy Feb 06 '13 at 20:11
-
@SridharRamakrishnan _i set with the contentpane() the layoutmanager setLayout(null)_ That's the worst idea one could have. This always leads to disastrous situation, horrible code to maintain and nightmare code to produce (and then later read). The ONLY way to work is to use appropriate LayoutManager's. Take a look a BorderLayout, GridBagLayout (and if you can have 3rd parties libraries, MigLayout) – Guillaume Polet Feb 06 '13 at 23:15
1 Answers
1
if im giving the initial setSize(800,1000) in which i placed the textfields,labels,buttons etc..as per the size 800,1000 the application looks good,suppose im maximizing the window of the Frame, automatically the textfields,labels,buttons are kept in the static way...
- for
AbsoluteLayout
to have to place theJComponent
by using theInsets
that came from firstcontainer
Is there any possibilities to scale the contents of the J Frame
have to use
ComponentListener
(notice delayed bySwing Timer
, because thisListener
firing a new event for every pixels on all directions) for scallingJComponents
together with containerthis is job only for
LayoutManager
, don't to supply that by usingAbsoluteLayout
&Insets
&ComponentListener
, be sure this code could be longer an more complicated than by usingGroupLayout

mKorbel
- 109,525
- 20
- 134
- 319