• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel  RSS feed

 
Ed Mirsky
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have a problem. I�m new at java and I need help showing and hiding a JPanel. I was able to do it in awt but not in swing.

I have an inner class:

public class MycanvasA extends java.awt.Canvas
{
public void paint(Graphics g)
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize();
//... stuff
}
}// class

I then create an instance of the canvas:

MycanvasA canvasA = new MycanvasA();

Since it extends java.awt.Canvas, I'm able to use setVisible to show or hide the canvas:
canvasA.setVisible(false);


I rewrote the application using swing:

public class MycanvasA extends javax.swing.JPanel
{
public void paintComponent(Graphics g)
{
//... stuff
}
}

HOW do I show or hide the canvas? I can't use:
canvasA.setVisible(false);


Thank you in advance,

Ed
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't you use setVisible()? What happens when you do?

Layne
 
Sunil Kumar Gupta
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the problem using setVisible(false)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!