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 / First Aid / September 2005

Tip: Looking for answers? Try searching our database.

A bigger Window

Thread view: 
jalkadir - 13 Sep 2005 18:46 GMT
>From the book Mastering Java 2 -1.4 form SYBEX, I have this code
--- snip

public class Picasso extends ExitableJFrame{
        Insets insets;
        public void paint(Graphics g) {
            super.paint(g);
            if(insets == null) {
                insets = getInsets();
            }
            g.translate(insets.left, insets.top);
            g.fillRect(30,10,200,300);
            g.clearRect(50,30,70,50);
            g.drawRect(60,50,40,20);
            g.drawLine(10,55,250,55);
        }
        public static void main(String args[]) {
            Frame f = new Picasso();
            f.setTitle("Picasso");
            f.setSize(900,900); // Size of the window !!!
            f.pack();
            f.setVisible(true);
            //f.show(); //Method obsolete ?
        }
    }
-- end --
But the window is *waaaay too small and none of the graphics get
displayed, when I drag the window to a larger size, I can see the the
graphics are there, but when I let go of the mouse button the images no
longer appear on the window.
How can I get Java to display the window in a size that would be more
convenient?

TIA.
Oliver Wong - 13 Sep 2005 19:01 GMT
> >From the book Mastering Java 2 -1.4 form SYBEX, I have this code
> public class Picasso extends ExitableJFrame{
[snip]
> public static void main(String args[]) {
> Frame f = new Picasso();
[quoted text clipped - 8 lines]
> But the window is *waaaay too small and none of the graphics get
> displayed

   Not sure what an ExitableJFrame is, but if it's anything like a JFrame,
then pack() will resize the window, so the setSize(900,900) called earlier
is essentially useless.

   - Oliver
Roedy Green - 13 Sep 2005 20:45 GMT
>        f.setSize(900,900); // Size of the window !!!
>            f.pack();

pack says shrink the window to the smallest possible size that will
still hold everything.

You meant to say f.validate() which leaves the window at 900,900 and
just adjusts the components inside.

See http://mindprod.com/jgloss/validate.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



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.