title: Assign function to Jbutton
body: <p>I have a few classes to create a very simple GUI (<code>JFrame</code>) with a few objects like a JTabbedPanel and a <code>JTree</code>. And one of the classes that creates a ribbon in the <code>JTabbedPanel</code> creates a <code>JButton</code>, that should have a function that updates the <code>JTree</code>.</p>
  
  <p>I do have some getter, but I have no idea how to use the <code>JButton</code> to update something on an object that gets created in the main method (the GUI object, from where I would be able to get to the <code>JTree</code>).</p>
  
  <p>How do I update something on an object that gets created in the main method in the actual class of the <code>JButton</code>?</p>
  
  <p>I might have to change the structure of my project.</p>
  
  <pre><code>public class Gui extends JFrame{
  private Ribbon ribbon;
  private Status status;
  public Panel panel;
  
  public Gui(){
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setTitle("INIT TITLE");
      setExtendedState(Frame.MAXIMIZED_BOTH);     
      setMinimumSize(new Dimension(600,400));
      setVisible(true);
      try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      } catch (Exception e) {
            e.printStackTrace();
      }
  
      ribbon = new Ribbon();
      add(ribbon, BorderLayout.NORTH);        
      status = new Status();
      add(status, BorderLayout.SOUTH);
      panel = new Panel();
      add(panel, JSplitPane.HORIZONTAL_SPLIT);
      //panel.setLeftComponent(panel.getTree());
      //panel.openProject();
      setVisible(true);
      panel.loadProject();
  }
  </code></pre>
  
  <p>The Ribbon doesnt do a lot:</p>
  
  <p>public class Ribbon extends JTabbedPane {</p>
  
  <pre><code>public Ribbon(){
  
      addTab("Home", null, new RibbonHome());
      addTab("Import", null, new RibbonImport());
      addTab("Options", null, new RibbonOptions());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But the Ribbon-Tab creates some buttons:</p>
  
  <pre><code>public class RibbonHome extends JPanel{
  private JButton b1, b2, b3;
  
  public RibbonHome(){
      b1 = new JButton("test1");
      b2 = new JButton("test2");
      b3 = new JButton("test3");
      add(b1);
      add(b2);
      add(b3);
  
      b1.addActionListener(new ActionListener() {
  
  
          @Override
          public void actionPerformed(ActionEvent arg0) {
               //UPDATE the JTree 
          }
      });      
  
  }
  
  }
  </code></pre>