DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    4

    JButton hides in a JFRAME

    I have create an application that is a JFrame I have created a class that extneds Jbutton.

    I have added the extended JButton to the Jframe but it hides it only appears if I roolover it or click it.

    The JFrame adds the JButton as normal
    getContentPane().add(MyButton);

    In the JFrame I overide the paint method to draw an image

    void paint(Graphics g){
    g.drawImage(.........);
    }

    how can I make the Button appear.

    thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    4
    Could you please post the code of the file. Are u running the setVisible method from within the constructor, or r u not using it at all. Just post the code, and we'll see what can be done about it.
    Find great java apps. Get your java apps rated - http://www.thejavahub.com

  3. #3
    Join Date
    Aug 2004
    Posts
    4

    thanks

    I have managed to figure this out

    I was not calling super.paint in the paint method when I did the JButtons painted correctly my backgroud was no long white though.

    to solve the white issue in the constructor i called

    getContentPane().setBackground(Color.WHITE);

    rather than just

    setBackground(Color.WHITE);

    this seemed to solve my issues but thanks anyway.
    I have another issue though which I have posted as another thread. it is regarding the components are coved up if I paint and image in the paint method like

    g.DrawImage(..........);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links