java - JButton action in other class -


i have main frame 2 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 menu panel, want make button, sets fahrtenbearbeiten panel's visible(false). problem is: how can reach action triggered in menu panel (menu.java) , has action in other file (haupt.java)?

  1. declare fahrtenbearbeiten jpanel global variable

    private jpanel fahrtenbearbeitenpnl = new jpanel(); 
  2. create method

    public void hidefahrtenbearbeitenpnl() {    fahrtenbearbeitenpnl.setvisible(false); } 
  3. call method on object of class contains panel. example:

    menu.hidefahrtenbearbeitenpnl(); 

let me know if i've got question wrong. (maybe post whole class(es) easier support)


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -