tags:

views:

428

answers:

2

Hi guys,

I am making a Desktop Application using Netbeans 6.8. What I would like to do is to programmatically set the size of my Application so that it fills the entire screen. I have looked around and it seems to be quite a nasty problem. I have been trying the code shown here, but it doesn't seem to be working.

Anyone has any idea on how I can solve it?

+1  A: 

If you are using a JFrame then try calling:

   setExtendedState(Frame.MAXIMIZED_BOTH);

on your FRame.

Vincent Ramdhanie
No Luck.I called it in the constructor of the FrameView, bother before and after the initComponents method. I also tried calling .repaint(), .validate() and .validate() but it didn't work either.
npinti
You can set the extended state before the frame is visible. If the frame is NOT maximized then its because the Desktop Application code is invoking frame.pack() or frame.setSize(...) after you have invoked the setExtendedState() method. So search your source code to see where this is being done and then invoke your code after this. This is a problem with the Application Framework, not Swing.
camickr
I looked at the Generated code, and at the class that calls the FrameView, but I did not see any setSize or pack call. I checked with the Navigator thing and it did specify a specific size. When I changed it how ever, the Frame's size only changed when it was in the Designer, when I ran the application the FrameView kept the same size.I'll keep messing around and will try to keep you posted.
npinti
A: 

Thanks guys, it seems that all I needed was to mix the answers given above. I am answering this question so that I can put in some formatted code so that it will be easier to understand should someone stumble upon this post :)

    super(app);
    JFrame frame = new JFrame();
    frame.pack();
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setResizable(false);
    this.setFrame(frame);
    initComponents();

I basically created another JFrame and set it as the FrameView's JFrame before the initComponents method.

npinti