It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes problem with the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with the code" Watch "problem with the code" New topic

problem with the code

in.anurag Singh

Joined: May 14, 2010
Posts: 25

I have a problem with the above code.
The program is compiling successfully and is running but i am not getting the panel containing rectangle on the main Frame.
The main Frame is displaying only the comboboxes, there should be a rectangle also..

Please solve the problem..
Jhedzkie Skies
Ranch Hand

Joined: Oct 28, 2009
Posts: 118
please use codetags next time.
in.anurag Singh

Joined: May 14, 2010
Posts: 25
i will take care of that..this is my first time to have the problem with the code so sorry..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10825

You can use the button to incorporate the code tags in your original post

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
pete stein

Joined: Feb 23, 2007
Posts: 1561
Your drawrectangle class as shown:

attempts to draw a 150 x 100 point rectangle with the rectangle's top left corner at [200, 50]. However when you create one in your main class:

you only give it a size of 150 x 50, so how will this rectangle ever show if it starts at 200, 50?

Also, you avoid using null layout and setBounds but instead let layout managers do the component laying for you.
in.anurag Singh

Joined: May 14, 2010
Posts: 25

This makes my code run and a rectangle is now appearing..
Thanks a lot..

I will now try this by layout managers..

I agree. Here's the link:
subject: problem with the code
It's not a secret anymore!