Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

Maximized JFrame

Thread view: 
RatTee - 29 Feb 2004 18:08 GMT
I don't manage to get a maximized JFrame automatically.  I have to do
it manually.  After hours of search, I just don't find the way to do
it.  Can anyone help me?  Where is my fault in the code?

import java.awt.*;
import javax.swing.*;

public class Test
{
    static JFrame venster=new JFrame("Testvenster");
   
    public static void main(String[]args)
    {
        Toolkit tkit=venster.getToolkit();
        Dimension vensterGrootte=tkit.getScreenSize();
       
        int vensterBreedte=vensterGrootte.width;
        int vensterHoogte=vensterGrootte.height;
        int positieBreedte=0;
        int positieHoogte=0;

venster.setBounds(positieBreedte,positieHoogte,vensterBreedte,vensterHoogte);
venster.setExtendedState(JFrame.MAXIMIZED_BOTH);

        venster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        venster.setVisible(true);
    }   
}
Andrew Thompson - 29 Feb 2004 19:33 GMT
> I don't manage to get a maximized JFrame automatically.  I have to do
> it manually.  After hours of search, I just don't find the way to do
> it.  Can anyone help me?  Where is my fault in the code?

I do not quite understand you.

Move the stuff you have in main into the
constructor of 'Test' (poor name for _any_
class btw), and those things happen
'automatically' on each frame you instantiate.

Something like this..
______________
import java.awt.*;
import javax.swing.*;

public class FullScreenFrame extends JFrame
{
    static int positieBreedte=0;
    static int positieHoogte=0;

    FullScreenFrame()
    {
        Toolkit tkit=getToolkit();
        Dimension vensterGrootte=tkit.getScreenSize();

        int vensterBreedte=vensterGrootte.width/2;
        int vensterHoogte=vensterGrootte.height/2;

    setBounds(positieBreedte+=10,positieHoogte+=10,
        vensterBreedte,vensterHoogte);
    // setExtendedState(JFrame.MAXIMIZED_BOTH);

        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setVisible(true);
    }

    public static void main(String[]args)
    {
        for (int ii=0; ii<20; ii++)
        {
            FullScreenFrame fsf1 = new FullScreenFrame();
        }
    }
}
_______________
If that is not what you mean, perhaps
you will need to clarify.

If it _is_ what you mean, you would
be better off using comp.lang.java.help
for the moment.

Signature

Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.