Results 1 to 2 of 2
  1. #1
    augustas656 is offline Senior Member
    Join Date
    Apr 2014
    Location
    United Kingdom
    Posts
    193
    Rep Power
    6

    Default How to reload JFrame with updated settings

    I have a JFrame initialization method in my class that extends Canvas:

    Java Code:
    		setMinimumSize(getDimension());
    		setPreferredSize(getDimension());
    		setMaximumSize(getDimension());
    		
    		frame = new JFrame(settings.getGameName());
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setLayout(new BorderLayout());
    		frame.setSize(getDimension());
    		
    		if (settings.getFullscreen()) {
    			frame.setUndecorated(true);
    			frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    		} else {
    			frame.setUndecorated(false);
    			frame.setExtendedState(JFrame.NORMAL);
    			frame.setLocationRelativeTo(null);
    		}
    		
    		frame.add(this, BorderLayout.CENTER);
    		frame.setResizable(false);
    		frame.setVisible(true);
    		frame.pack();
    so the method getFullscreen() returns a boolean value of wether my game should be fullscreen or not. What should I do if I wanted to change from windowed to fullscreen or vice-versa, I can't do frame.setUndecorated(false) whilst the frame is running, how do I make this work?
    Regards
    augustas656

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How to reload JFrame with updated settings

    A displayable frame's decoration cannot be changed. So you will have to write code to "mimic" what you want to do. Also, what about the other problems you are having? Have you solved them yet? I would recommend you focus on one issue at a time.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. how do i reload my program?
    By ytrewqc in forum New To Java
    Replies: 4
    Last Post: 11-05-2011, 01:39 PM
  2. reload the value of the variable
    By kiranjava in forum Advanced Java
    Replies: 1
    Last Post: 05-05-2010, 08:20 AM
  3. Properties reload
    By koala993 in forum Advanced Java
    Replies: 0
    Last Post: 04-29-2010, 05:39 PM
  4. How to reload JInternalFrame
    By chyrl in forum AWT / Swing
    Replies: 42
    Last Post: 04-16-2010, 01:29 PM
  5. how to reload a jsp page
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-14-2007, 11:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •