Reputation: 1
I have a main Frame with two panels:
JPanel Menu = new Menu();
Menu.setBounds(0, 37, 300, 644);
contentPane.add(Menu);
Menu.setVisible(false);
JPanel Fahrtenbearbeiten = new Fahrtenbearbeiten();
Fahrtenbearbeiten.setBounds(0, 0, 1422, 668);
contentPane.add(Fahrtenbearbeiten);
In the Menu panel, I want to make a button, who sets the Fahrtenbearbeiten
panel's Visible(false)
. The Problem is: How can I reach an action which is triggered in the Menu panel (Menu.java
) and has an action in an other file (Haupt.java
)?
Upvotes: 0
Views: 49
Reputation: 843
Declare the Fahrtenbearbeiten
JPanel as global variable
private JPanel fahrtenbearbeitenPnl = new JPanel();
Create a method
public void hideFahrtenbearbeitenPnl()
{
fahrtenbearbeitenPnl.setVisible(false);
}
Call this method on the object of the class which contains the panel. For example:
menu.hideFahrtenbearbeitenPnl();
Let me know if I've got your question wrong. (Maybe post the whole class(es) for easier support)
Upvotes: 2