File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes How to access? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How to access?" Watch "How to access?" New topic

How to access?

Robert Ploch

Joined: Jun 05, 2002
Posts: 19
Imagine i had these classes:
class myApplet extends JApplet{
JPanel x = new myPanel();
JPanel y = new my2Panel();
class myPanel extends JPanel {
JButton button = new JButton();

class my2Panel extends JPanel {

Now when a user hits the button in myPanel, can i directly access the draw-method in my2Panel?
I would try using the getContentPane()-method, but dont know if it works and how...
Is it possible?
Maybe this diagram would help, this is the big brother of the situation described above:
(in the diagram it is Gui=myApplet and the surrounding Panels are myPanel,my2Panel and so on)
With regards
Robert Ploch
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

If you define your draw method as:

You could do my2Panel.draw().

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Your other option would be to do something like:

And this way would probably be preferred.
I agree. Here's the link:
subject: How to access?
Similar Threads
Please help with scope of panels...
where to define my menubar
Problem with custom painting and multiple JPanel
about drawing