• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to start a JFrame in maximized mode  RSS feed

 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to computationally maximize my JFrame (behavior like pressing the windows maximize button (middle one)).
I would have suspected some methods in java.awt.Window, but haven't found anyone.
Have anyone tried this?
Thanks,
Steffen
 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.awt.Frame.setExtendedState()
In myJFrame:
setExtendedState(MAXIMIZED_BOTH);
I used setState, which was "obsolete" (not deprecated) and didn't work.
Gotta stop replying myself....
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is new to me, thanks for the tip.
but I have another one, I just found it:
file:///local_home/lib/j2sdk1.4_api/docs/api/java/awt/GraphicsDevice.html#setFullScreenWindow(java.awt.Window)
I have not tried it yet, so I don't know if it works ok. it's new in 1.4 that might explain why it's not that known.
have you worked with GraphicsEnvironment yet?
c
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, here is the www link :roll:
"http://java.sun.com/j2se/1.4/docs/api/java/awt/GraphicsDevice.html#setFullSreenWindow(java.awt.Window)"
c
 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi c.
Isn't there a difference between maximized state (Frame is as big as possible, but still with the frame borders visible) and full-screen mode (e.g. DVD-players)?
I haven't used the GraphicsDevice package, but isn't it more graphics-oriented? Maybe it can help me with my }&%##!!! update problems on our splash-screen.
Thanks,
Steffen
 
Jaunty John
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try this:
[CODE]
import java.awt.*;//Where the Toolkit is located, I think
public class jFileFormat extends JFrame
{
//... Var declarations
//--+-- --+-- --+-- --+-- --+-- --+-- --+-- --+-- --+-- --+-- --+--
public jFileFormat()
{
//CONSTRUCTOR
super("Johns jFileFormat");//The JFrame Title
Toolkit tk = Toolkit.getDefaultToolkit();//see Cay Horstman, p. 273 , Core Java I
Dimension d = tk.getScreenSize(); //Gets the user screen size
int scrnHigh = d.height; //Pulls out the High
int scrnWide = d.width; //Pulls out the Wide
//setSize(scrnWide *9/10, scrnHigh *9/10);//sets screen to 0.9 size
setSize(scrnWide, scrnHigh);//sets screen to FULL size
//setLocation(scrnWide *1/20, scrnHigh *1/20);//CENTER it for 9/10th size
setLocation(0, 0);//
Image icn = tk.getImage("snp_bluT.gif");//Frame Icon
this.setIconImage(icn);//Set Icon
//... CONSTRUCTOR More code
}//~End of CONSTRUCTOR
// ... CLASS code continues
}//~END of CLASS
[!CODE]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!