• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Auto Maximise GUI

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have the following code :
import java.awt.*;
public class TestFlow extends Frame {
public static void main(String args[]) {
Panel p = new Panel();
Button b = new Button("NORTH");
Button b1 = new Button("SOUTH");
Button b2 = new Button("CENTER");
TestFlow t = new TestFlow();
t.setSize(450,450);
t.setVisible(true);
t.add(p);
p.add(b);
p.add(b1);
p.add(b2);
}
}
How do I maximise the panel to be the size of my Monitor screen ?

Thanks in advance.
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi you can use this
Dimenstion d = getToolkit().getDefaultScreenSize();
i can't remember the exact method but something like this and then set it to setSize(d)
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The last I heard, there was no way to programatically maximize a window without using JNI. The best you can do is set its size equal to the size of your screen (which isn't really the same as miximizing it). There are some resources on the internet that show how you can do this using JNI, if you're interested.
 
Zahid, Butt
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Bodie, could you please give me URL's that further explain your comments.
Thanks.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java doesn't provide any way to maximize a JFrame. On a Windows platform, this can only be achieved via the use of native code. This requires using JNI to integrate native code with your Java program. You can find a JNI tutorial here. I used to have a link to some C code that handled the maximization of the window, but I can't find it now that I need it. Sorry.
HTH
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic