1

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

mKorbel
  • 109,525
  • 20
  • 134
  • 319
JAVA Beginner
  • 389
  • 3
  • 15
  • 2
    What'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
  • 1
    Sergiy 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 Answers1

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 the JComponent by using the Insets that came from first container

Is there any possibilities to scale the contents of the J Frame

  • have to use ComponentListener (notice delayed by Swing Timer, because this Listener firing a new event for every pixels on all directions) for scalling JComponents together with container

  • this is job only for LayoutManager, don't to supply that by using AbsoluteLayout & Insets & ComponentListener, be sure this code could be longer an more complicated than by using GroupLayout

mKorbel
  • 109,525
  • 20
  • 134
  • 319