0

i was trying to make my JFrame form responsive according to screen size but when try my code it doesnt comes up and if i remove the code it works fine.here is my code

Home frame = new Home();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int i = screen.width;
    int j = screen.height;
    frame.setSize(i, j);

please help

mKorbel
  • 109,525
  • 20
  • 134
  • 319
sahib
  • 85
  • 1
  • 13

2 Answers2

3

To enlarge the frame to occupy the full-screen size, use:

frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 

To make the swing components responsive and adapting the frame size, use layout managers (e.g. FlowLayout):

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
  • i have to change the size of inner element also which will then again need to customised for which i need get this code to work i don't want alternative. i just want this code to be corrected – sahib Feb 04 '16 at 10:01
-1

i got the answer. and it was really very simple i just need to put

this.setResizable(flase);

in my constructor.my coding was right

sahib
  • 85
  • 1
  • 13