JButton hides in a JFRAME


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: JButton hides in a JFRAME

  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(..........);

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center