How you can modify a JPanel where is in one class, from a different class? I have a JPanel and i want to setIcon() from other class.
Thank you
3 replies to this topic
#1
Posted 08 May 2011 - 01:53 PM
|
|
|
#2
Posted 08 May 2011 - 09:13 PM
public class Gui extends JFrame{
private JPanel;
public void setPanelIcon(...){
jPanel.setIcon(...);
}
}
public class Other{
public static void main(String[] args){
Gui gui = new Gui();
gui.setPanelIcon(...);
}
}
#3
Posted 09 May 2011 - 01:14 AM
The class Other, should be main?
#4
Posted 10 May 2011 - 08:10 AM
No, I just showed that the class containing the JPanel should get a method which allows other classes to use that method, and in the method the JPanel changes.
So even tho "Other" class doesn't know the Gui's JPanel, it can call a method of Gui, and Gui will do it itself.
So even tho "Other" class doesn't know the Gui's JPanel, it can call a method of Gui, and Gui will do it itself.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









